net: Add preliminaly support for suspending/resuming a net interface

Such state needs to be set _from_ the PM API functions and not the other
way round. So if a network device driver does not support such API, it
will not be able to set the core net_if on PM state, obviously.

Currently, these functions only set/unset NET_IF_SUSPENDED flag.

More logic will be added later, to decide whether the net_if can be
actually set to suspend mode or not and also to take care of all timers
related to the interface.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2020-02-25 09:42:35 +01:00 committed by Jukka Rissanen
commit 80917ec16f
3 changed files with 62 additions and 1 deletions

View file

@ -194,6 +194,9 @@ enum net_if_flag {
*/
NET_IF_NO_AUTO_START,
/** Power management specific: interface is being suspended */
NET_IF_SUSPENDED,
/** @cond INTERNAL_HIDDEN */
/* Total number of flags - must be at the end of the enum */
NET_IF_NUM_FLAGS
@ -2129,6 +2132,28 @@ static inline bool net_if_are_pending_tx_packets(struct net_if *iface)
#endif
}
#ifdef CONFIG_NET_POWER_MANAGEMENT
/**
* @brief Suspend a network interface from a power management perspective
*
* @param iface Pointer to network interface
*
* @return 0 on success, or -EALREADY/-EBUSY as possible errors.
*/
int net_if_suspend(struct net_if *iface);
/**
* @brief Resume a network interface from a power management perspective
*
* @param iface Pointer to network interface
*
* @return 0 on success, or -EALREADY as a possible error.
*/
int net_if_resume(struct net_if *iface);
#endif /* CONFIG_NET_POWER_MANAGEMENT */
/** @cond INTERNAL_HIDDEN */
struct net_if_api {
void (*init)(struct net_if *iface);