netdev_lowerhalf: add reclaim callback in netdev_ops_s

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu 2024-08-05 18:02:36 +08:00 committed by Xiang Xiao
parent ff7eda46e7
commit d740a8e73c
2 changed files with 14 additions and 1 deletions

View file

@ -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;
}
/****************************************************************************

View file

@ -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