net: if: Add function to check any pending TX packets
This function can be used for example by network power management to check if the network interface can be suspended or not. If there are network packets in transmit queue, then the network interface cannot be suspended yet. Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
parent
15dfa28c2e
commit
dee07c9e0a
2 changed files with 46 additions and 2 deletions
|
@ -469,6 +469,14 @@ struct net_if {
|
|||
|
||||
/** Network interface instance configuration */
|
||||
struct net_if_config config;
|
||||
|
||||
#if defined(CONFIG_NET_POWER_MANAGEMENT)
|
||||
/** Keep track of packets pending in traffic queues. This is
|
||||
* needed to avoid putting network device driver to sleep if
|
||||
* there are packets waiting to be sent.
|
||||
*/
|
||||
int tx_pending;
|
||||
#endif
|
||||
} __net_if_align;
|
||||
|
||||
/**
|
||||
|
@ -2101,6 +2109,26 @@ void net_if_unset_promisc(struct net_if *iface);
|
|||
*/
|
||||
bool net_if_is_promisc(struct net_if *iface);
|
||||
|
||||
/**
|
||||
* @brief Check if there are any pending TX network data for a given network
|
||||
* interface.
|
||||
*
|
||||
* @param iface Pointer to network interface
|
||||
*
|
||||
* @return True if there are pending TX network packets for this network
|
||||
* interface, False otherwise.
|
||||
*/
|
||||
static inline bool net_if_are_pending_tx_packets(struct net_if *iface)
|
||||
{
|
||||
#if defined(CONFIG_NET_POWER_MANAGEMENT)
|
||||
return !!iface->tx_pending;
|
||||
#else
|
||||
ARG_UNUSED(iface);
|
||||
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @cond INTERNAL_HIDDEN */
|
||||
struct net_if_api {
|
||||
void (*init)(struct net_if *iface);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue