anchao commented on code in PR #6464:
URL: https://github.com/apache/incubator-nuttx/pull/6464#discussion_r899839598


##########
drivers/wireless/ieee80211/bcm43xxx/bcmf_driver.c:
##########
@@ -1370,15 +1396,256 @@ int bcmf_wl_set_mode(FAR struct bcmf_dev_s *priv, 
struct iwreq *iwr)
 
   out_len = 4;
   value = iwr->u.mode == IW_MODE_INFRA ? 1 : 0;
-  if (bcmf_cdc_ioctl(priv, interface, true,
-                     WLC_SET_INFRA, (uint8_t *)&value, &out_len))
+
+  return bcmf_cdc_ioctl(priv, interface, true,
+                        WLC_SET_INFRA, (uint8_t *)&value, &out_len);
+}
+
+int bcmf_wl_get_mode(FAR struct bcmf_dev_s *priv, struct iwreq *iwr)
+{
+  uint32_t out_len;
+  uint32_t infra;
+  int interface;
+  uint32_t ap;
+  int ret;
+
+  interface = bcmf_wl_get_interface(priv, iwr);
+
+  if (interface < 0)
     {
-      return -EIO;
+      return -EINVAL;
+    }
+
+  out_len = 4;
+  ret = bcmf_cdc_ioctl(priv, interface, false,
+                       WLC_GET_INFRA, (uint8_t *)&infra, &out_len);
+  if (ret == OK)
+    {
+      out_len = 4;
+      ret = bcmf_cdc_ioctl(priv, interface, false,
+                           WLC_GET_AP, (uint8_t *)&ap, &out_len);
+    }
+
+  if (ret == OK)
+    {
+      if (infra == 0)
+        {
+          iwr->u.mode = IW_MODE_ADHOC;
+        }
+      else if (ap)
+        {
+          iwr->u.mode = IW_MODE_MASTER;
+        }
+      else
+        {
+          iwr->u.mode = IW_MODE_INFRA;
+        }
+    }
+
+  return ret;
+}
+
+int bcmf_wl_set_bssid(FAR struct bcmf_dev_s *priv, struct iwreq *iwr)
+{
+  uint32_t out_len;
+  int interface;
+  int ap = 0;
+  int ret;
+
+  interface = bcmf_wl_get_interface(priv, iwr);
+
+  if (interface < 0)
+    {
+      return -EINVAL;
+    }
+
+  out_len = 4;
+  ret = bcmf_cdc_ioctl(priv, interface, false, WLC_GET_AP,
+                       (uint8_t *)&ap, &out_len);
+  if (ret == OK)
+    {
+      out_len = sizeof(struct ether_addr);
+      ret = bcmf_cdc_ioctl(priv, interface, true,
+                           (ap ? WLC_SET_BSSID : WLC_REASSOC),
+                           (uint8_t *)iwr->u.ap_addr.sa_data, &out_len);
+    }
+
+  return ret;
+}
+
+int bcmf_wl_get_bssid(FAR struct bcmf_dev_s *priv, struct iwreq *iwr)
+{
+  uint32_t out_len;
+  int interface;
+
+  interface = bcmf_wl_get_interface(priv, iwr);
+
+  if (interface < 0)
+    {
+      return -EINVAL;
+    }
+
+  iwr->u.ap_addr.sa_family = ARPHRD_ETHER;
+  out_len = sizeof(struct ether_addr);
+
+  return bcmf_cdc_ioctl(priv, interface, false, WLC_GET_BSSID,
+                        (uint8_t *)iwr->u.ap_addr.sa_data, &out_len);
+}
+
+int bcmf_wl_get_channel(FAR struct bcmf_dev_s *priv, struct iwreq *iwr)
+{
+  channel_info_t ci;
+  uint32_t out_len;
+  int interface;
+  int ret;
+
+  interface = bcmf_wl_get_interface(priv, iwr);
+
+  if (interface < 0)
+    {
+      return -EINVAL;
+    }
+
+  out_len = sizeof(ci);
+
+  ret = bcmf_cdc_ioctl(priv, interface, false,
+                       WLC_GET_CHANNEL, (uint8_t *)&ci, &out_len);
+  if (ret == OK)
+    {
+      iwr->u.freq.m = bcmf_wl_channel_to_frequency(ci.target_channel);
+    }
+
+  return ret;
+}
+
+int bcmf_wl_get_rate(FAR struct bcmf_dev_s *priv, struct iwreq *iwr)
+{
+  uint32_t out_len;
+  uint32_t rate;
+  int interface;
+  int ret;
+
+  interface = bcmf_wl_get_interface(priv, iwr);
+
+  if (interface < 0)
+    {
+      return -EINVAL;
+    }
+
+  out_len = 4;
+  ret = bcmf_cdc_ioctl(priv, interface, false,
+                       WLC_GET_RATE, (uint8_t *)&rate, &out_len);
+  if (ret == OK)
+    {
+      iwr->u.bitrate.value = ((rate / 2) * 1000) + ((rate & 1) ? 500 : 0);
+      iwr->u.bitrate.fixed = 1;
+    }
+
+  return ret;
+}
+
+int bcmf_wl_get_txpower(FAR struct bcmf_dev_s *priv, struct iwreq *iwr)
+{
+  uint32_t out_len;
+  int interface;
+  int radio;
+  int ret;
+
+  interface = bcmf_wl_get_interface(priv, iwr);
+
+  if (interface < 0)
+    {
+      return -EINVAL;
+    }
+
+  out_len = 4;

Review Comment:
   Done



##########
drivers/wireless/ieee80211/bcm43xxx/bcmf_driver.c:
##########
@@ -1370,15 +1396,256 @@ int bcmf_wl_set_mode(FAR struct bcmf_dev_s *priv, 
struct iwreq *iwr)
 
   out_len = 4;
   value = iwr->u.mode == IW_MODE_INFRA ? 1 : 0;
-  if (bcmf_cdc_ioctl(priv, interface, true,
-                     WLC_SET_INFRA, (uint8_t *)&value, &out_len))
+
+  return bcmf_cdc_ioctl(priv, interface, true,
+                        WLC_SET_INFRA, (uint8_t *)&value, &out_len);
+}
+
+int bcmf_wl_get_mode(FAR struct bcmf_dev_s *priv, struct iwreq *iwr)
+{
+  uint32_t out_len;
+  uint32_t infra;
+  int interface;
+  uint32_t ap;
+  int ret;
+
+  interface = bcmf_wl_get_interface(priv, iwr);
+
+  if (interface < 0)
     {
-      return -EIO;
+      return -EINVAL;
+    }
+
+  out_len = 4;
+  ret = bcmf_cdc_ioctl(priv, interface, false,
+                       WLC_GET_INFRA, (uint8_t *)&infra, &out_len);
+  if (ret == OK)
+    {
+      out_len = 4;
+      ret = bcmf_cdc_ioctl(priv, interface, false,
+                           WLC_GET_AP, (uint8_t *)&ap, &out_len);
+    }
+
+  if (ret == OK)
+    {
+      if (infra == 0)
+        {
+          iwr->u.mode = IW_MODE_ADHOC;
+        }
+      else if (ap)
+        {
+          iwr->u.mode = IW_MODE_MASTER;
+        }
+      else
+        {
+          iwr->u.mode = IW_MODE_INFRA;
+        }
+    }
+
+  return ret;
+}
+
+int bcmf_wl_set_bssid(FAR struct bcmf_dev_s *priv, struct iwreq *iwr)
+{
+  uint32_t out_len;
+  int interface;
+  int ap = 0;
+  int ret;
+
+  interface = bcmf_wl_get_interface(priv, iwr);
+
+  if (interface < 0)
+    {
+      return -EINVAL;
+    }
+
+  out_len = 4;
+  ret = bcmf_cdc_ioctl(priv, interface, false, WLC_GET_AP,
+                       (uint8_t *)&ap, &out_len);
+  if (ret == OK)
+    {
+      out_len = sizeof(struct ether_addr);
+      ret = bcmf_cdc_ioctl(priv, interface, true,
+                           (ap ? WLC_SET_BSSID : WLC_REASSOC),
+                           (uint8_t *)iwr->u.ap_addr.sa_data, &out_len);
+    }
+
+  return ret;
+}
+
+int bcmf_wl_get_bssid(FAR struct bcmf_dev_s *priv, struct iwreq *iwr)
+{
+  uint32_t out_len;
+  int interface;
+
+  interface = bcmf_wl_get_interface(priv, iwr);
+
+  if (interface < 0)
+    {
+      return -EINVAL;
+    }
+
+  iwr->u.ap_addr.sa_family = ARPHRD_ETHER;
+  out_len = sizeof(struct ether_addr);
+
+  return bcmf_cdc_ioctl(priv, interface, false, WLC_GET_BSSID,
+                        (uint8_t *)iwr->u.ap_addr.sa_data, &out_len);
+}
+
+int bcmf_wl_get_channel(FAR struct bcmf_dev_s *priv, struct iwreq *iwr)
+{
+  channel_info_t ci;
+  uint32_t out_len;
+  int interface;
+  int ret;
+
+  interface = bcmf_wl_get_interface(priv, iwr);
+
+  if (interface < 0)
+    {
+      return -EINVAL;
+    }
+
+  out_len = sizeof(ci);
+
+  ret = bcmf_cdc_ioctl(priv, interface, false,
+                       WLC_GET_CHANNEL, (uint8_t *)&ci, &out_len);
+  if (ret == OK)
+    {
+      iwr->u.freq.m = bcmf_wl_channel_to_frequency(ci.target_channel);
+    }
+
+  return ret;
+}
+
+int bcmf_wl_get_rate(FAR struct bcmf_dev_s *priv, struct iwreq *iwr)
+{
+  uint32_t out_len;
+  uint32_t rate;
+  int interface;
+  int ret;
+
+  interface = bcmf_wl_get_interface(priv, iwr);
+
+  if (interface < 0)
+    {
+      return -EINVAL;
+    }
+
+  out_len = 4;
+  ret = bcmf_cdc_ioctl(priv, interface, false,
+                       WLC_GET_RATE, (uint8_t *)&rate, &out_len);
+  if (ret == OK)
+    {
+      iwr->u.bitrate.value = ((rate / 2) * 1000) + ((rate & 1) ? 500 : 0);
+      iwr->u.bitrate.fixed = 1;
+    }
+
+  return ret;
+}
+
+int bcmf_wl_get_txpower(FAR struct bcmf_dev_s *priv, struct iwreq *iwr)
+{
+  uint32_t out_len;
+  int interface;
+  int radio;
+  int ret;
+
+  interface = bcmf_wl_get_interface(priv, iwr);
+
+  if (interface < 0)
+    {
+      return -EINVAL;
+    }
+
+  out_len = 4;
+  ret = bcmf_cdc_ioctl(priv, interface, false,
+                       WLC_GET_RADIO, (uint8_t *)&radio, &out_len);
+  if (ret == OK)
+    {
+      out_len = 4;

Review Comment:
   Done



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to