netdev/upper: Make quota_load public
Signed-off-by: Zhe Weng <wengzhe@xiaomi.com>
This commit is contained in:
parent
6ede91c5e7
commit
483eb10f37
@ -106,23 +106,6 @@ static int quota_fetch_dec(FAR struct netdev_lowerhalf_s *lower,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: quota_load
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* Fetch the quota, works like atomic_load.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
static int quota_load(FAR struct netdev_lowerhalf_s *lower,
|
|
||||||
enum netpkt_type_e type)
|
|
||||||
{
|
|
||||||
irqstate_t flags = spin_lock_irqsave(NULL);
|
|
||||||
int ret = lower->quota[type];
|
|
||||||
spin_unlock_irqrestore(NULL, flags);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: netpkt_get
|
* Name: netpkt_get
|
||||||
*
|
*
|
||||||
@ -232,7 +215,7 @@ netdev_upper_alloc(FAR struct netdev_lowerhalf_s *dev)
|
|||||||
|
|
||||||
static inline bool netdev_upper_can_tx(FAR struct netdev_upperhalf_s *upper)
|
static inline bool netdev_upper_can_tx(FAR struct netdev_upperhalf_s *upper)
|
||||||
{
|
{
|
||||||
return quota_load(upper->lower, NETPKT_TX) > 0;
|
return netdev_lower_quota_load(upper->lower, NETPKT_TX) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -840,6 +823,27 @@ void netdev_lower_txdone(FAR struct netdev_lowerhalf_s *dev)
|
|||||||
netdev_upper_queue_work(&dev->netdev);
|
netdev_upper_queue_work(&dev->netdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: netdev_lower_quota_load
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Fetch the quota, works like atomic_load.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - The lower half device driver structure
|
||||||
|
* type - Whether get quota for TX or RX
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int netdev_lower_quota_load(FAR struct netdev_lowerhalf_s *dev,
|
||||||
|
enum netpkt_type_e type)
|
||||||
|
{
|
||||||
|
irqstate_t flags = spin_lock_irqsave(NULL);
|
||||||
|
int ret = dev->quota[type];
|
||||||
|
spin_unlock_irqrestore(NULL, flags);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: netpkt_alloc
|
* Name: netpkt_alloc
|
||||||
*
|
*
|
||||||
|
@ -234,6 +234,21 @@ void netdev_lower_rxready(FAR struct netdev_lowerhalf_s *dev);
|
|||||||
|
|
||||||
void netdev_lower_txdone(FAR struct netdev_lowerhalf_s *dev);
|
void netdev_lower_txdone(FAR struct netdev_lowerhalf_s *dev);
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: netdev_lower_quota_load
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Fetch the quota, use this interface when device is running.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* dev - The lower half device driver structure
|
||||||
|
* type - Whether get quota for TX or RX
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int netdev_lower_quota_load(FAR struct netdev_lowerhalf_s *dev,
|
||||||
|
enum netpkt_type_e type);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: netpkt_alloc
|
* Name: netpkt_alloc
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user