Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion arch/risc-v/src/common/espressif/esp_wlan_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ struct esp_wlan_priv_s
struct esp_common_wifi_s *common;
uint32_t mode;

spinlock_t rx_lock;
netpkt_queue_t netdev_rx_queue;
uint8_t flatbuf[CONFIG_NET_ETH_PKTSIZE];
};
Expand Down Expand Up @@ -212,6 +213,7 @@ static int esp_wlan_ifup(struct netdev_lowerhalf_s *dev)
{
struct esp_wlan_priv_s *priv = (struct esp_wlan_priv_s *)dev;
struct net_driver_s *netdev = &priv->dev.netdev;
irqstate_t flags;
int ret = OK;

#ifdef CONFIG_NET_IPv4
Expand All @@ -228,7 +230,9 @@ static int esp_wlan_ifup(struct netdev_lowerhalf_s *dev)

/* Clear RX queue */

flags = spin_lock_irqsave(&priv->rx_lock);
netpkt_free_queue(&priv->netdev_rx_queue);
spin_unlock_irqrestore(&priv->rx_lock, flags);

/* Start Wi-Fi interface */

Expand Down Expand Up @@ -349,7 +353,13 @@ static int esp_wlan_transmit(struct netdev_lowerhalf_s *dev,
static netpkt_t *esp_wlan_receive(struct netdev_lowerhalf_s *dev)
{
struct esp_wlan_priv_s *priv = (struct esp_wlan_priv_s *)dev;
netpkt_t *pkt = netpkt_remove_queue(&priv->netdev_rx_queue);
irqstate_t flags;
netpkt_t *pkt;

flags = spin_lock_irqsave(&priv->rx_lock);
pkt = netpkt_remove_queue(&priv->netdev_rx_queue);
spin_unlock_irqrestore(&priv->rx_lock, flags);

return pkt;
}

Expand Down Expand Up @@ -1008,6 +1018,7 @@ void IRAM_ATTR esp_wifi_tx_done_cb(uint8_t ifidx,
static int wlan_rx_done(struct esp_wlan_priv_s *priv,
void *buffer, uint16_t len, void *eb)
{
irqstate_t flags;
int ret = OK;
netpkt_t *pkt = NULL;

Expand All @@ -1025,7 +1036,9 @@ static int wlan_rx_done(struct esp_wlan_priv_s *priv,
goto out;
}

flags = spin_lock_irqsave(&priv->rx_lock);
ret = netpkt_tryadd_queue(pkt, &priv->netdev_rx_queue);
spin_unlock_irqrestore(&priv->rx_lock, flags);
if (ret < 0)
{
wlerr("ERROR: Failed to add packet to queue\n");
Expand Down Expand Up @@ -1221,6 +1234,7 @@ static int esp_wlan_initialize(uint32_t mode)
priv->dev.rxtype = NETDEV_RX_THREAD;
priv->dev.priority = 100;

spin_lock_init(&priv->rx_lock);
IOB_QINIT(&priv->netdev_rx_queue);

/* Register RX done callback. Called when the RX packet is received. */
Expand Down
16 changes: 15 additions & 1 deletion arch/xtensa/src/common/espressif/esp_wlan_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ struct esp_wlan_priv_s
struct esp_common_wifi_s *common;
uint32_t mode;

spinlock_t rx_lock;
netpkt_queue_t netdev_rx_queue;
uint8_t flatbuf[CONFIG_NET_ETH_PKTSIZE];
};
Expand Down Expand Up @@ -212,6 +213,7 @@ static int esp_wlan_ifup(struct netdev_lowerhalf_s *dev)
{
struct esp_wlan_priv_s *priv = (struct esp_wlan_priv_s *)dev;
struct net_driver_s *netdev = &priv->dev.netdev;
irqstate_t flags;
int ret = OK;

#ifdef CONFIG_NET_IPv4
Expand All @@ -228,7 +230,9 @@ static int esp_wlan_ifup(struct netdev_lowerhalf_s *dev)

/* Clear RX queue */

flags = spin_lock_irqsave(&priv->rx_lock);
netpkt_free_queue(&priv->netdev_rx_queue);
spin_unlock_irqrestore(&priv->rx_lock, flags);

/* Start Wi-Fi interface */

Expand Down Expand Up @@ -349,7 +353,13 @@ static int esp_wlan_transmit(struct netdev_lowerhalf_s *dev,
static netpkt_t *esp_wlan_receive(struct netdev_lowerhalf_s *dev)
{
struct esp_wlan_priv_s *priv = (struct esp_wlan_priv_s *)dev;
netpkt_t *pkt = netpkt_remove_queue(&priv->netdev_rx_queue);
irqstate_t flags;
netpkt_t *pkt;

flags = spin_lock_irqsave(&priv->rx_lock);
pkt = netpkt_remove_queue(&priv->netdev_rx_queue);
spin_unlock_irqrestore(&priv->rx_lock, flags);

return pkt;
}

Expand Down Expand Up @@ -1008,6 +1018,7 @@ void IRAM_ATTR esp_wifi_tx_done_cb(uint8_t ifidx,
static int wlan_rx_done(struct esp_wlan_priv_s *priv,
void *buffer, uint16_t len, void *eb)
{
irqstate_t flags;
int ret = OK;
netpkt_t *pkt = NULL;

Expand All @@ -1025,7 +1036,9 @@ static int wlan_rx_done(struct esp_wlan_priv_s *priv,
goto out;
}

flags = spin_lock_irqsave(&priv->rx_lock);
ret = netpkt_tryadd_queue(pkt, &priv->netdev_rx_queue);
spin_unlock_irqrestore(&priv->rx_lock, flags);
if (ret != OK)
{
wlerr("ERROR: Failed to add packet to queue\n");
Expand Down Expand Up @@ -1224,6 +1237,7 @@ static int esp_wlan_initialize(uint32_t mode)
priv->dev.rxtype = NETDEV_RX_THREAD;
priv->dev.priority = 100;

spin_lock_init(&priv->rx_lock);
IOB_QINIT(&priv->netdev_rx_queue);

/* Register RX done callback. Called when the RX packet is received. */
Expand Down
Loading