This is an old revision of the document!
Overview
Setting/detecting carrier, and the subsequent implications of setting net_device_ops ndo_change_carrier field.
include/linux/netdevice.h
Net device state:
struct net_device {
... snip ...
unsigned long state;
... snip ...
State flag bits for later testing:
enum netdev_state_t {
__LINK_STATE_START,
__LINK_STATE_PRESENT,
__LINK_STATE_NOCARRIER,
__LINK_STATE_LINKWATCH_PENDING,
__LINK_STATE_DORMANT,
};
Check if carrier is present on device:
/**
* netif_carrier_ok - test if carrier present
* @dev: network device
*
* Check if carrier is present on device
*/
static inline bool netif_carrier_ok(const struct net_device *dev)
{
return !test_bit(__LINK_STATE_NOCARRIER, &dev->state);
}
void netif_carrier_on(struct net_device *dev);
void netif_carrier_off(struct net_device *dev);