You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2023/06/15 22:32:05 UTC
[nuttx] 01/02: netdev/upper: Make quota_load public
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 483eb10f37626aa23514fcc21f7d441b4b7df0a0
Author: Zhe Weng <we...@xiaomi.com>
AuthorDate: Tue May 23 20:17:24 2023 +0800
netdev/upper: Make quota_load public
Signed-off-by: Zhe Weng <we...@xiaomi.com>
---
drivers/net/netdev_upperhalf.c | 40 ++++++++++++++++++++----------------
include/nuttx/net/netdev_lowerhalf.h | 15 ++++++++++++++
2 files changed, 37 insertions(+), 18 deletions(-)
diff --git a/drivers/net/netdev_upperhalf.c b/drivers/net/netdev_upperhalf.c
index b2fb591778..db144235d2 100644
--- a/drivers/net/netdev_upperhalf.c
+++ b/drivers/net/netdev_upperhalf.c
@@ -106,23 +106,6 @@ static int quota_fetch_dec(FAR struct netdev_lowerhalf_s *lower,
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
*
@@ -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)
{
- 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);
}
+/****************************************************************************
+ * 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
*
diff --git a/include/nuttx/net/netdev_lowerhalf.h b/include/nuttx/net/netdev_lowerhalf.h
index 6fdf35872d..958505801a 100644
--- a/include/nuttx/net/netdev_lowerhalf.h
+++ b/include/nuttx/net/netdev_lowerhalf.h
@@ -234,6 +234,21 @@ void netdev_lower_rxready(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
*