This is an old revision of the document!


Setting/detecting carrier, and the subsequent implications of setting net_device_ops ndo_change_carrier field.

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);
  • ndo_change_carrier.1533384840.txt.gz
  • Last modified: 2018/08/04 12:14
  • by rpjday