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/18 21:11:00 UTC

[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6471: wireless/bcm43xxx: enable power saving on netdev up/down

pkarashchenko commented on code in PR #6471:
URL: https://github.com/apache/incubator-nuttx/pull/6471#discussion_r901015987


##########
drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c:
##########
@@ -636,20 +637,54 @@ void bcmf_netdev_notify_rx(FAR struct bcmf_dev_s *priv)
 static int bcmf_ifup(FAR struct net_driver_s *dev)
 {
   FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private;
+  irqstate_t flags;
+  uint32_t out_len;
+  int ret;
 
-#ifdef CONFIG_NET_IPv4
-  ninfo("Bringing up: %d.%d.%d.%d\n",
-        (int)(dev->d_ipaddr & 0xff),
-        (int)((dev->d_ipaddr >> 8) & 0xff),
-        (int)((dev->d_ipaddr >> 16) & 0xff),
-        (int)(dev->d_ipaddr >> 24));
-#endif
-#ifdef CONFIG_NET_IPv6
-  ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
-        dev->d_ipv6addr[0], dev->d_ipv6addr[1], dev->d_ipv6addr[2],
-        dev->d_ipv6addr[3], dev->d_ipv6addr[4], dev->d_ipv6addr[5],
-        dev->d_ipv6addr[6], dev->d_ipv6addr[7]);
-#endif
+  /* Disable the hardware interrupt */
+
+  flags = enter_critical_section();
+
+  if (priv->bc_bifup)
+    {
+      goto errout_in_critical_section;
+    }
+
+  ret = bcmf_wl_active(priv, true);
+  if (ret == OK)
+    {
+      /* Enable chip */
+
+      ret = bcmf_wl_enable(priv, true);
+    }
+
+  if (ret != OK)
+    {
+      goto errout_in_critical_section;

Review Comment:
   Do we need to call `bcmf_wl_active(priv, false);` here?



##########
drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c:
##########
@@ -636,20 +637,54 @@ void bcmf_netdev_notify_rx(FAR struct bcmf_dev_s *priv)
 static int bcmf_ifup(FAR struct net_driver_s *dev)
 {
   FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private;
+  irqstate_t flags;
+  uint32_t out_len;
+  int ret;
 
-#ifdef CONFIG_NET_IPv4
-  ninfo("Bringing up: %d.%d.%d.%d\n",
-        (int)(dev->d_ipaddr & 0xff),
-        (int)((dev->d_ipaddr >> 8) & 0xff),
-        (int)((dev->d_ipaddr >> 16) & 0xff),
-        (int)(dev->d_ipaddr >> 24));
-#endif
-#ifdef CONFIG_NET_IPv6
-  ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
-        dev->d_ipv6addr[0], dev->d_ipv6addr[1], dev->d_ipv6addr[2],
-        dev->d_ipv6addr[3], dev->d_ipv6addr[4], dev->d_ipv6addr[5],
-        dev->d_ipv6addr[6], dev->d_ipv6addr[7]);
-#endif
+  /* Disable the hardware interrupt */
+
+  flags = enter_critical_section();
+
+  if (priv->bc_bifup)
+    {
+      goto errout_in_critical_section;
+    }
+
+  ret = bcmf_wl_active(priv, true);
+  if (ret == OK)
+    {
+      /* Enable chip */
+
+      ret = bcmf_wl_enable(priv, true);
+    }
+
+  if (ret != OK)
+    {
+      goto errout_in_critical_section;
+    }
+
+  /* Set customized MAC address */
+
+  if (bcmf_board_etheraddr(&priv->bc_dev.d_mac.ether))
+    {
+      out_len = ETHER_ADDR_LEN;
+      bcmf_cdc_iovar_request(priv, CHIP_STA_INTERFACE, true,
+                             IOVAR_STR_CUR_ETHERADDR,
+                             priv->bc_dev.d_mac.ether.ether_addr_octet,
+                             &out_len);
+    }
+
+  /* Query MAC address */
+
+  out_len = ETHER_ADDR_LEN;
+  ret = bcmf_cdc_iovar_request(priv, CHIP_STA_INTERFACE, false,
+                             IOVAR_STR_CUR_ETHERADDR,
+                             priv->bc_dev.d_mac.ether.ether_addr_octet,
+                             &out_len);

Review Comment:
   ```suggestion
     ret = bcmf_cdc_iovar_request(priv, CHIP_STA_INTERFACE, false,
                                  IOVAR_STR_CUR_ETHERADDR,
                                  priv->bc_dev.d_mac.ether.ether_addr_octet,
                                  &out_len);
   ```



##########
drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c:
##########
@@ -685,22 +727,25 @@ static int bcmf_ifdown(FAR struct net_driver_s *dev)
 {
   FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private;
   irqstate_t flags;
+  int ret = OK;

Review Comment:
   why do we need `ret`? `OK` only is returned anyway



##########
drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c:
##########
@@ -659,9 +694,16 @@ static int bcmf_ifup(FAR struct net_driver_s *dev)
   bcmf_ipv6multicast(priv);
 #endif
 
+  leave_critical_section(flags);
+

Review Comment:
   ```suggestion
   ```



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