Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| ndo_change_carrier [2018/08/04 12:16] – [include/linux/netdevice.h] rpjday | ndo_change_carrier [2018/08/04 17:31] (current) – [Overview] rpjday | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ===== Overview ===== | ===== Overview ===== | ||
| - | Setting/ | + | Setting/ |
| ===== Normal behaviour ===== | ===== Normal behaviour ===== | ||
| - | ==== include/ | + | ==== Net device state ==== |
| + | |||
| + | From '' | ||
| Net device state: | Net device state: | ||
| Line 28: | Line 30: | ||
| </ | </ | ||
| - | Check if carrier | + | ==== Checking for state of carrier |
| + | |||
| + | Again from '' | ||
| < | < | ||
| Line 46: | Line 50: | ||
| </ | </ | ||
| - | ==== net/ | + | ==== Test for interface running ==== |
| + | |||
| + | Still in '' | ||
| + | |||
| + | < | ||
| + | /** | ||
| + | | ||
| + | | ||
| + | * | ||
| + | | ||
| + | */ | ||
| + | static inline bool netif_running(const struct net_device *dev) | ||
| + | { | ||
| + | return test_bit(__LINK_STATE_START, | ||
| + | } | ||
| + | </ | ||
| + | ==== Test if carrier on or off ==== | ||
| + | |||
| + | From '' | ||
| + | |||
| + | < | ||
| + | /** | ||
| + | | ||
| + | | ||
| + | * | ||
| + | * Device has detected that carrier. | ||
| + | */ | ||
| + | void netif_carrier_on(struct net_device *dev) | ||
| + | { | ||
| + | if (test_and_clear_bit(__LINK_STATE_NOCARRIER, | ||
| + | if (dev-> | ||
| + | return; | ||
| + | atomic_inc(& | ||
| + | linkwatch_fire_event(dev); | ||
| + | if (netif_running(dev)) | ||
| + | __netdev_watchdog_up(dev); | ||
| + | } | ||
| + | } | ||
| + | EXPORT_SYMBOL(netif_carrier_on); | ||
| + | |||
| + | /** | ||
| + | | ||
| + | | ||
| + | * | ||
| + | * Device has detected loss of carrier. | ||
| + | */ | ||
| + | void netif_carrier_off(struct net_device *dev) | ||
| + | { | ||
| + | if (!test_and_set_bit(__LINK_STATE_NOCARRIER, | ||
| + | if (dev-> | ||
| + | return; | ||
| + | atomic_inc(& | ||
| + | linkwatch_fire_event(dev); | ||
| + | } | ||
| + | } | ||
| + | EXPORT_SYMBOL(netif_carrier_off); | ||
| + | </ | ||