You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/06/20 10:39:36 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6488: wireless/bcm43xxx: add auto power saving support

xiaoxiang781216 commented on code in PR #6488:
URL: https://github.com/apache/incubator-nuttx/pull/6488#discussion_r901516939


##########
drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c:
##########
@@ -778,6 +859,9 @@ static int bcmf_txavail(FAR struct net_driver_s *dev)
 {
   FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private;
 
+#ifdef CONFIG_IEEE80211_BROADCOM_LOWPOWER
+  bcmf_lowpower_poll(priv);

Review Comment:
   put to work thread?



##########
drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c:
##########
@@ -755,6 +768,74 @@ static int bcmf_ifdown(FAR struct net_driver_s *dev)
   return OK;
 }
 
+/****************************************************************************
+ * Name: bcmf_lowpower_work
+ *
+ * Description:
+ *   Process low power saving dueto work timer expiration
+ *
+ * Input Parameters:
+ *   arg - context of device to use
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_IEEE80211_BROADCOM_LOWPOWER
+static void bcmf_lowpower_work(FAR void *arg)
+{
+  FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)arg;
+  clock_t cticks = clock_systime_ticks();
+
+  if (!priv->bc_bifup)
+    {
+      return;
+    }
+
+  if (TICK2SEC(cticks - priv->lp_time) >=
+      CONFIG_IEEE80211_BROADCOM_LOWPOWER_TIMEOUT)
+    {
+      bcmf_wl_set_pm(priv, PM_MAX);

Review Comment:
   where PM_MAX?



##########
drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c:
##########
@@ -755,6 +768,74 @@ static int bcmf_ifdown(FAR struct net_driver_s *dev)
   return OK;
 }
 
+/****************************************************************************
+ * Name: bcmf_lowpower_work
+ *
+ * Description:
+ *   Process low power saving dueto work timer expiration
+ *
+ * Input Parameters:
+ *   arg - context of device to use
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_IEEE80211_BROADCOM_LOWPOWER
+static void bcmf_lowpower_work(FAR void *arg)
+{
+  FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)arg;
+  clock_t cticks = clock_systime_ticks();
+
+  if (!priv->bc_bifup)
+    {
+      return;
+    }
+
+  if (TICK2SEC(cticks - priv->lp_time) >=
+      CONFIG_IEEE80211_BROADCOM_LOWPOWER_TIMEOUT)
+    {
+      bcmf_wl_set_pm(priv, PM_MAX);
+      priv->lp_pending = false;
+    }
+  else
+    {
+      cticks = SEC2TICK(CONFIG_IEEE80211_BROADCOM_LOWPOWER_TIMEOUT) -
+               (cticks - priv->lp_time);
+      work_queue(LPWORK, &priv->lp_work, bcmf_lowpower_work, priv, cticks);
+    }
+}
+
+/****************************************************************************
+ * Name: bcmf_lowpower_poll
+ *
+ * Description:
+ *   Polling low power
+ *
+ * Input Parameters:
+ *   arg - context of device to use
+ *
+ ****************************************************************************/
+
+static void bcmf_lowpower_poll(FAR struct bcmf_dev_s *priv)
+{
+  if (priv->bc_bifup)
+    {
+      priv->lp_time = clock_systime_ticks();
+      if (priv->lp_mode != PM_FAST)
+        {
+          bcmf_wl_set_pm(priv, PM_FAST);
+        }
+
+      if (work_available(&priv->lp_work) && !priv->lp_pending)

Review Comment:
   lp_pending don't need, it's enough to check work_available



##########
drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c:
##########
@@ -742,6 +750,11 @@ static int bcmf_ifdown(FAR struct net_driver_s *dev)
 
   if (priv->bc_bifup)
     {
+      if (!work_available(&priv->lp_work))

Review Comment:
   need guard by CONFIG_IEEE80211_BROADCOM_LOWPOWER



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org