mirror of
https://github.com/apache/nuttx.git
synced 2026-05-12 09:48:31 +08:00
netdev_lowerhalf: add reclaim callback in netdev_ops_s
Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
@@ -264,7 +264,16 @@ netdev_upper_alloc(FAR struct netdev_lowerhalf_s *dev)
|
||||
|
||||
static inline bool netdev_upper_can_tx(FAR struct netdev_upperhalf_s *upper)
|
||||
{
|
||||
return netdev_lower_quota_load(upper->lower, NETPKT_TX) > 0;
|
||||
FAR struct netdev_lowerhalf_s *lower = upper->lower;
|
||||
int quota = netdev_lower_quota_load(lower, NETPKT_TX);
|
||||
|
||||
if (quota <= 0 && lower->ops->reclaim)
|
||||
{
|
||||
lower->ops->reclaim(lower);
|
||||
quota = netdev_lower_quota_load(lower, NETPKT_TX);
|
||||
}
|
||||
|
||||
return quota > 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -168,6 +168,10 @@ struct netdev_ops_s
|
||||
int (*ioctl)(FAR struct netdev_lowerhalf_s *dev, int cmd,
|
||||
unsigned long arg);
|
||||
#endif
|
||||
|
||||
/* reclaim - try to reclaim packets sent by netdev. */
|
||||
|
||||
void (*reclaim)(FAR struct netdev_lowerhalf_s *dev);
|
||||
};
|
||||
|
||||
/* This structure is a set of wireless handlers, leave unsupported operations
|
||||
|
||||
Reference in New Issue
Block a user