Skip to content

Commit

Permalink
net: if: Only start the network interface during init if needed
Browse files Browse the repository at this point in the history
If the NET_IF_NO_AUTO_START network interface flag is set, then
do not take network interface up during the initialization of the
network interface. The network device driver can set the flag in its
network interface initialization function if needed.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
  • Loading branch information
jukkar committed Apr 23, 2019
1 parent 712103d commit 3633951
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions include/net/net_if.h
Expand Up @@ -179,6 +179,14 @@ enum net_if_flag {
/** Interface is in promiscuous mode */
NET_IF_PROMISC,

/** Do not start the interface immediately after initialization.
* This requires that either the device driver or some other entity
* will need to manually take the interface up when needed.
* For example for Ethernet this will happen when the driver calls
* the net_eth_carrier_on() function.
*/
NET_IF_NO_AUTO_START,

/** @cond INTERNAL_HIDDEN */
/* Total number of flags - must be at the end of the enum */
NET_IF_NUM_FLAGS
Expand Down
4 changes: 3 additions & 1 deletion subsys/net/ip/net_if.c
Expand Up @@ -3154,6 +3154,8 @@ void net_if_post_init(void)

/* After TX is running, attempt to bring the interface up */
for (iface = __net_if_start; iface != __net_if_end; iface++) {
net_if_up(iface);
if (!net_if_flag_is_set(iface, NET_IF_NO_AUTO_START)) {
net_if_up(iface);
}
}
}

0 comments on commit 3633951

Please sign in to comment.