You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/07/02 11:24:39 UTC

[incubator-nuttx] branch master updated (14f1519d1e -> ba3e859aa5)

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


    from 14f1519d1e wireless/bcm43xxx: discard auth event if netdev down
     new 5ce7b35020 wireless/bcm43xxx: replace private queue implement to list_node
     new ba3e859aa5 wireless/bcm43xxx: allocate tx frame with nonblock mode

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c |  2 +-
 drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.c   | 32 +++++--------
 drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.h   | 10 ++--
 drivers/wireless/ieee80211/bcm43xxx/bcmf_sdpcm.c  | 58 ++++++++---------------
 drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.c  | 47 ------------------
 drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.h  |  7 ---
 6 files changed, 39 insertions(+), 117 deletions(-)


[incubator-nuttx] 02/02: wireless/bcm43xxx: allocate tx frame with nonblock mode

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit ba3e859aa5b0ce5c5537d98fcc55a443b2b81f0b
Author: chao.an <an...@xiaomi.com>
AuthorDate: Sun Jun 26 20:12:11 2022 +0800

    wireless/bcm43xxx: allocate tx frame with nonblock mode
    
    Signed-off-by: chao.an <an...@xiaomi.com>
---
 drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c b/drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c
index 051a8a66ea..616b8cd587 100644
--- a/drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c
+++ b/drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c
@@ -147,7 +147,7 @@ int bcmf_netdev_alloc_tx_frame(FAR struct bcmf_dev_s *priv)
   /* Allocate frame for TX */
 
   priv->cur_tx_frame = bcmf_bdc_allocate_frame(priv,
-                                               MAX_NETDEV_PKTSIZE, true);
+                                               MAX_NETDEV_PKTSIZE, false);
   if (!priv->cur_tx_frame)
     {
       wlerr("ERROR: Cannot allocate TX frame\n");


[incubator-nuttx] 01/02: wireless/bcm43xxx: replace private queue implement to list_node

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 5ce7b3502096e506c8f1f735bab1812a8428adbc
Author: chao.an <an...@xiaomi.com>
AuthorDate: Sat Jul 2 12:39:48 2022 +0800

    wireless/bcm43xxx: replace private queue implement to list_node
    
    Signed-off-by: chao.an <an...@xiaomi.com>
---
 drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.c  | 32 ++++++-------
 drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.h  | 10 ++--
 drivers/wireless/ieee80211/bcm43xxx/bcmf_sdpcm.c | 58 ++++++++----------------
 drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.c | 47 -------------------
 drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.h |  7 ---
 5 files changed, 38 insertions(+), 116 deletions(-)

diff --git a/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.c b/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.c
index f62db26830..53f78ed1d2 100644
--- a/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.c
+++ b/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.c
@@ -31,7 +31,6 @@
 #include <stdio.h>
 #include <debug.h>
 #include <errno.h>
-#include <queue.h>
 #include <assert.h>
 
 #include <nuttx/kmalloc.h>
@@ -832,9 +831,9 @@ int bcmf_bus_sdio_initialize(FAR struct bcmf_dev_s *priv,
       goto exit_free_bus;
     }
 
-  dq_init(&sbus->tx_queue);
-  dq_init(&sbus->rx_queue);
-  dq_init(&sbus->free_queue);
+  list_initialize(&sbus->tx_queue);
+  list_initialize(&sbus->rx_queue);
+  list_initialize(&sbus->free_queue);
 
   /* Setup free buffer list */
 
@@ -842,7 +841,7 @@ int bcmf_bus_sdio_initialize(FAR struct bcmf_dev_s *priv,
 
   for (ret = 0; ret < CONFIG_IEEE80211_BROADCOM_FRAME_POOL_SIZE; ret++)
     {
-      bcmf_dqueue_push(&sbus->free_queue, &g_pktframes[ret].list_entry);
+      list_add_tail(&sbus->free_queue, &g_pktframes[ret].list_entry);
     }
 
   /* Init thread semaphore */
@@ -964,7 +963,7 @@ int bcmf_sdio_thread(int argc, char **argv)
       /* Check if RX/TX frames are available */
 
       if ((sbus->intstatus & I_HMB_FRAME_IND) == 0 &&
-          (sbus->tx_queue.tail == NULL) &&
+          list_is_empty(&sbus->tx_queue) &&
           !sbus->irq_pending)
         {
           /* Wait for event (device interrupt or user request) */
@@ -1055,7 +1054,6 @@ struct bcmf_sdio_frame *bcmf_sdio_allocate_frame(FAR struct bcmf_dev_s *priv,
 {
   FAR struct bcmf_sdio_dev_s *sbus = (FAR struct bcmf_sdio_dev_s *)priv->bus;
   struct bcmf_sdio_frame *sframe;
-  dq_entry_t *entry = NULL;
 
   while (1)
     {
@@ -1068,7 +1066,9 @@ struct bcmf_sdio_frame *bcmf_sdio_allocate_frame(FAR struct bcmf_dev_s *priv,
           sbus->tx_queue_count <
             CONFIG_IEEE80211_BROADCOM_FRAME_POOL_SIZE / 2)
         {
-          if ((entry = bcmf_dqueue_pop_tail(&sbus->free_queue)) != NULL)
+          if ((sframe = list_remove_head_type(&sbus->free_queue,
+                                         struct bcmf_sdio_frame,
+                                         list_entry)) != NULL)
             {
               if (tx)
                 {
@@ -1082,21 +1082,15 @@ struct bcmf_sdio_frame *bcmf_sdio_allocate_frame(FAR struct bcmf_dev_s *priv,
 
       nxsem_post(&sbus->queue_mutex);
 
-      if (block)
+      if (!block)
         {
-          /* TODO use signaling semaphore */
-
-          wlinfo("alloc failed %d\n", tx);
-          nxsig_usleep(100 * 1000);
-          continue;
+          wlinfo("No avail buffer\n");
+          return NULL;
         }
 
-      wlinfo("No avail buffer\n");
-      return NULL;
+      nxsig_usleep(10 * 1000);
     }
 
-  sframe = container_of(entry, struct bcmf_sdio_frame, list_entry);
-
   sframe->header.len  = HEADER_SIZE + MAX_NETDEV_PKTSIZE +
                         CONFIG_NET_GUARDSIZE;
   sframe->header.base = sframe->data;
@@ -1115,7 +1109,7 @@ void bcmf_sdio_free_frame(FAR struct bcmf_dev_s *priv,
       DEBUGPANIC();
     }
 
-  bcmf_dqueue_push(&sbus->free_queue, &sframe->list_entry);
+  list_add_head(&sbus->free_queue, &sframe->list_entry);
 
   if (sframe->tx)
     {
diff --git a/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.h b/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.h
index f5a076caf9..9fbb78f155 100644
--- a/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.h
+++ b/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdio.h
@@ -29,8 +29,8 @@
 
 #include <stdint.h>
 #include <stdbool.h>
-#include <queue.h>
 
+#include <nuttx/list.h>
 #include <nuttx/sdio.h>
 #include <nuttx/semaphore.h>
 
@@ -103,9 +103,9 @@ struct bcmf_sdio_dev_s
   bool    flow_ctrl;               /* Current flow control status */
 
   sem_t queue_mutex;               /* Lock for TX/RX/free queues */
-  dq_queue_t free_queue;           /* Queue of available frames */
-  dq_queue_t tx_queue;             /* Queue of frames to transmit */
-  dq_queue_t rx_queue;             /* Queue of frames used to receive */
+  struct list_node free_queue;     /* Queue of available frames */
+  struct list_node tx_queue;       /* Queue of frames to transmit */
+  struct list_node rx_queue;       /* Queue of frames used to receive */
   volatile int tx_queue_count;     /* Count of items in TX queue */
 };
 
@@ -115,7 +115,7 @@ struct bcmf_sdio_frame
 {
   struct bcmf_frame_s header;
   bool                tx;
-  dq_entry_t          list_entry;
+  struct list_node    list_entry;
   uint8_t             pad[CONFIG_IEEE80211_BROADCOM_DMABUF_ALIGNMENT -
                           FIRST_WORD_SIZE]
   aligned_data(CONFIG_IEEE80211_BROADCOM_DMABUF_ALIGNMENT);
diff --git a/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdpcm.c b/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdpcm.c
index edc632f80a..6097546a57 100644
--- a/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdpcm.c
+++ b/drivers/wireless/ieee80211/bcm43xxx/bcmf_sdpcm.c
@@ -33,7 +33,6 @@
 
 #include <stddef.h>
 #include <string.h>
-#include <queue.h>
 
 #include "bcmf_sdio.h"
 #include "bcmf_core.h"
@@ -313,7 +312,7 @@ int bcmf_sdpcm_readframe(FAR struct bcmf_dev_s *priv)
             DEBUGPANIC();
           }
 
-        bcmf_dqueue_push(&sbus->rx_queue, &sframe->list_entry);
+        list_add_tail(&sbus->rx_queue, &sframe->list_entry);
         nxsem_post(&sbus->queue_mutex);
 
         bcmf_netdev_notify_rx(priv);
@@ -342,12 +341,11 @@ int bcmf_sdpcm_sendframe(FAR struct bcmf_dev_s *priv)
 {
   int ret;
   bool is_txframe;
-  dq_entry_t *entry;
   struct bcmf_sdio_frame *sframe;
   struct bcmf_sdpcm_header *header;
   FAR struct bcmf_sdio_dev_s *sbus = (FAR struct bcmf_sdio_dev_s *)priv->bus;
 
-  if (sbus->tx_queue.tail == NULL)
+  if (list_is_empty(&sbus->tx_queue))
     {
       /* No more frames to send */
 
@@ -367,8 +365,10 @@ int bcmf_sdpcm_sendframe(FAR struct bcmf_dev_s *priv)
       DEBUGPANIC();
     }
 
-  entry = sbus->tx_queue.tail;
-  sframe = container_of(entry, struct bcmf_sdio_frame, list_entry);
+  sframe = list_remove_head_type(&sbus->tx_queue, struct bcmf_sdio_frame,
+                                 list_entry);
+  nxsem_post(&sbus->queue_mutex);
+
   header = (struct bcmf_sdpcm_header *)sframe->header.base;
 
   /* Set frame sequence id */
@@ -387,40 +387,22 @@ int bcmf_sdpcm_sendframe(FAR struct bcmf_dev_s *priv)
   ret = bcmf_transfer_bytes(sbus, true, 2, 0,
                             sframe->header.base,
                             sframe->header.len);
-  if (ret != OK)
+  if (ret == OK)
     {
-      /* TODO handle retry count and remove frame from queue + abort TX */
+      is_txframe = sframe->tx;
 
-      wlinfo("fail send frame %d\n", ret);
-      ret = -EIO;
-      goto exit_abort;
-    }
+      /* Free frame buffer */
 
-  /* Frame sent, remove it from queue */
-
-  bcmf_dqueue_pop_tail(&sbus->tx_queue);
-  nxsem_post(&sbus->queue_mutex);
-  is_txframe = sframe->tx;
-
-  /* Free frame buffer */
-
-  bcmf_sdio_free_frame(priv, sframe);
+      bcmf_sdio_free_frame(priv, sframe);
 
-  if (is_txframe)
-    {
-      /* Notify upper layer at least one TX buffer is available */
+      if (is_txframe)
+        {
+          /* Notify upper layer at least one TX buffer is available */
 
-      bcmf_netdev_notify_tx(priv);
+          bcmf_netdev_notify_tx(priv);
+        }
     }
 
-  return OK;
-
-exit_abort:
-#if 0
-  bcmf_sdpcm_txfail(sbus, false);
-#endif
-
-  nxsem_post(&sbus->queue_mutex);
   return ret;
 }
 
@@ -456,7 +438,7 @@ int bcmf_sdpcm_queue_frame(FAR struct bcmf_dev_s *priv,
       DEBUGPANIC();
     }
 
-  bcmf_dqueue_push(&sbus->tx_queue, &sframe->list_entry);
+  list_add_tail(&sbus->tx_queue, &sframe->list_entry);
 
   nxsem_post(&sbus->queue_mutex);
 
@@ -511,7 +493,6 @@ void bcmf_sdpcm_free_frame(FAR struct bcmf_dev_s *priv,
 
 struct bcmf_frame_s *bcmf_sdpcm_get_rx_frame(FAR struct bcmf_dev_s *priv)
 {
-  dq_entry_t *entry;
   struct bcmf_sdio_frame *sframe;
   FAR struct bcmf_sdio_dev_s *sbus = (FAR struct bcmf_sdio_dev_s *)priv->bus;
 
@@ -520,15 +501,16 @@ struct bcmf_frame_s *bcmf_sdpcm_get_rx_frame(FAR struct bcmf_dev_s *priv)
       DEBUGPANIC();
     }
 
-  entry = bcmf_dqueue_pop_tail(&sbus->rx_queue);
+  sframe = list_remove_head_type(&sbus->rx_queue,
+                                 struct bcmf_sdio_frame,
+                                 list_entry);
 
   nxsem_post(&sbus->queue_mutex);
 
-  if (entry == NULL)
+  if (sframe == NULL)
     {
       return NULL;
     }
 
-  sframe = container_of(entry, struct bcmf_sdio_frame, list_entry);
   return &sframe->header;
 }
diff --git a/drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.c b/drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.c
index 1a4f0e3ad8..b81ea7391b 100644
--- a/drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.c
+++ b/drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.c
@@ -27,7 +27,6 @@
 #include <time.h>
 #include <debug.h>
 #include <stdio.h>
-#include <queue.h>
 
 #include "bcmf_utils.h"
 
@@ -87,49 +86,3 @@ int bcmf_sem_wait(sem_t *sem, unsigned int timeout_ms)
 {
   return nxsem_tickwait_uninterruptible(sem, MSEC2TICK(timeout_ms));
 }
-
-void bcmf_dqueue_push(dq_queue_t *queue, dq_entry_t *entry)
-{
-  if (queue->head == NULL)
-    {
-      /* List is empty */
-
-      queue->tail = entry;
-
-      entry->flink = entry;
-      entry->blink = entry;
-    }
-  else
-    {
-      /* Insert entry at list head */
-
-      entry->flink = queue->head;
-      entry->blink = queue->tail;
-
-      queue->head->blink = entry;
-    }
-
-  queue->head = entry;
-}
-
-dq_entry_t *bcmf_dqueue_pop_tail(dq_queue_t *queue)
-{
-  dq_entry_t *entry = queue->tail;
-
-  if (queue->head == queue->tail)
-    {
-      /* List is empty */
-
-      queue->head = NULL;
-      queue->tail = NULL;
-    }
-  else
-    {
-      /* Pop from queue tail */
-
-      queue->tail = entry->blink;
-      entry->blink->flink = queue->head;
-    }
-
-  return entry;
-}
diff --git a/drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.h b/drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.h
index 9f99f665ad..a1165c3fa7 100644
--- a/drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.h
+++ b/drivers/wireless/ieee80211/bcm43xxx/bcmf_utils.h
@@ -26,13 +26,9 @@
  ****************************************************************************/
 
 #include <stdint.h>
-#include <queue.h>
 
 #include <nuttx/semaphore.h>
 
-#define container_of(ptr, type, member) \
-        (type *)((uint8_t *)(ptr) - offsetof(type, member))
-
 #ifndef min
 #define min(a,b) ((a) < (b) ? (a) : (b))
 #endif
@@ -49,9 +45,6 @@ void bcmf_hexdump(uint8_t *data, unsigned int len, unsigned long offset);
 
 int bcmf_sem_wait(sem_t *sem, unsigned int timeout_ms);
 
-dq_entry_t *bcmf_dqueue_pop_tail(dq_queue_t *queue);
-void bcmf_dqueue_push(dq_queue_t *queue, dq_entry_t *entry);
-
 static inline uint16_t bcmf_getle16(void *val)
 {
   uint8_t *valb = (uint8_t *)val;