wireless/bcm43xxx: replace private queue implement to list_node
Signed-off-by: chao.an <anchao@xiaomi.com>
This commit is contained in:
parent
14f1519d1e
commit
5ce7b35020
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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 */
|
||||
|
||||
bcmf_sdio_free_frame(priv, sframe);
|
||||
|
||||
if (is_txframe)
|
||||
{
|
||||
/* Notify upper layer at least one TX buffer is available */
|
||||
|
||||
bcmf_netdev_notify_tx(priv);
|
||||
}
|
||||
}
|
||||
|
||||
/* 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);
|
||||
|
||||
if (is_txframe)
|
||||
{
|
||||
/* Notify upper layer at least one TX buffer is available */
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user