net/devif: move preprocess of txpoll into common code

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2022-11-27 03:31:07 +08:00 committed by Xiang Xiao
parent db88554d7d
commit 8850dee746
61 changed files with 744 additions and 2381 deletions

View file

@ -1015,51 +1015,19 @@ static int c5471_txpoll(struct net_driver_s *dev)
{
struct c5471_driver_s *priv = (struct c5471_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
c5471_transmit(priv);
/* Check if the ESM has let go of the RX descriptor giving us
* access rights to submit another Ethernet frame.
*/
if (priv->c_dev.d_len > 0)
if ((EIM_TXDESC_OWN_HOST & getreg32(priv->c_rxcpudesc)) != 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
/* No, then return non-zero to terminate the poll */
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->c_dev.d_flags))
#endif
{
arp_out(&priv->c_dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->c_dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->c_dev))
{
/* Send the packet */
c5471_transmit(priv);
/* Check if the ESM has let go of the RX descriptor giving us
* access rights to submit another Ethernet frame.
*/
if ((EIM_TXDESC_OWN_HOST & getreg32(priv->c_rxcpudesc)) != 0)
{
/* No, then return non-zero to terminate the poll */
return 1;
}
}
return 1;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -1205,64 +1205,44 @@ static int gd32_tx_poll(struct net_driver_s *dev)
DEBUGASSERT(priv->dev.d_buf != NULL);
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
gd32_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
/* Check if the next TX descriptor is owned by the Ethernet DMA or
* CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission.
*
* In a race condition, ENET_TDES0_DAV may be cleared BUT still
* not available because gd32_freeframe() has not yet run. If
* gd32_freeframe() has run, the buffer1 pointer (tdes2) will be
* nullified (and inflight should be < CONFIG_gd32_ETH_NTXDESC).
*/
if (priv->dev.d_len > 0)
if ((priv->txhead->tdes0 & ENET_TDES0_DAV) != 0 ||
priv->txhead->tdes2 != 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
#ifdef CONFIG_NET_IPv4
return -EBUSY;
}
arp_out(&priv->dev);
/* We have the descriptor, we can continue the poll. Allocate a new
* buffer for the poll.
*/
#endif /* CONFIG_NET_IPv4 */
dev->d_buf = gd32_buf_alloc(priv);
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
/* We can't continue the poll if we have no buffers */
gd32_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
if (dev->d_buf == NULL)
{
/* Terminate the poll. */
/* Check if the next TX descriptor is owned by the Ethernet DMA or
* CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission.
*
* In a race condition, ENET_TDES0_DAV may be cleared BUT still
* not available because gd32_freeframe() has not yet run. If
* gd32_freeframe() has run, the buffer1 pointer (tdes2) will be
* nullified (and inflight should be < CONFIG_gd32_ETH_NTXDESC).
*/
if ((priv->txhead->tdes0 & ENET_TDES0_DAV) != 0 ||
priv->txhead->tdes2 != 0)
{
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
return -EBUSY;
}
/* We have the descriptor, we can continue the poll. Allocate a new
* buffer for the poll.
*/
dev->d_buf = gd32_buf_alloc(priv);
/* We can't continue the poll if we have no buffers */
if (dev->d_buf == NULL)
{
/* Terminate the poll. */
return -ENOMEM;
}
}
return -ENOMEM;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -705,53 +705,19 @@ static int imx_txpoll(struct net_driver_s *dev)
struct imx_driver_s *priv =
(struct imx_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
imx_transmit(priv);
priv->dev.d_buf = (uint8_t *)
imx_swap32((uint32_t)priv->txdesc[priv->txhead].data);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
ninfo("Poll result: d_len=%d\n", priv->dev.d_len);
if (priv->dev.d_len > 0)
if (imx_txringfull(priv))
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
imx_transmit(priv);
priv->dev.d_buf = (uint8_t *)
imx_swap32((uint32_t)priv->txdesc[priv->txhead].data);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (imx_txringfull(priv))
{
return -EBUSY;
}
}
return -EBUSY;
}
/* If zero is returned, the polling will continue until

View file

@ -747,51 +747,19 @@ static int imxrt_txpoll(struct net_driver_s *dev)
struct imxrt_driver_s *priv =
(struct imxrt_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
imxrt_transmit(priv);
priv->dev.d_buf = (uint8_t *)
imxrt_swap32((uint32_t)priv->txdesc[priv->txhead].data);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (priv->dev.d_len > 0)
if (imxrt_txringfull(priv))
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
imxrt_transmit(priv);
priv->dev.d_buf = (uint8_t *)
imxrt_swap32((uint32_t)priv->txdesc[priv->txhead].data);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (imxrt_txringfull(priv))
{
return -EBUSY;
}
}
return -EBUSY;
}
/* If zero is returned, the polling will continue until

View file

@ -772,23 +772,20 @@ static int imxrt_txpoll(struct net_driver_s *dev)
if (priv->dev.d_len > 0)
{
if (!devif_loopback(&priv->dev))
imxrt_txdone(priv);
/* Send the packet */
imxrt_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (imxrt_txringfull(priv))
{
imxrt_txdone(priv);
/* Send the packet */
imxrt_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (imxrt_txringfull(priv))
{
spin_unlock_irqrestore(NULL, flags);
return -EBUSY;
}
spin_unlock_irqrestore(NULL, flags);
return -EBUSY;
}
}

View file

@ -531,51 +531,19 @@ static int kinetis_txpoll(struct net_driver_s *dev)
struct kinetis_driver_s *priv =
(struct kinetis_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
kinetis_transmit(priv);
priv->dev.d_buf = (uint8_t *)
kinesis_swap32((uint32_t)priv->txdesc[priv->txhead].data);
/* Check if there is room in the device to hold another packet.
* If not, return a non-zero value to terminate the poll.
*/
if (priv->dev.d_len > 0)
if (kinetis_txringfull(priv))
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
kinetis_transmit(priv);
priv->dev.d_buf = (uint8_t *)
kinesis_swap32((uint32_t)priv->txdesc[priv->txhead].data);
/* Check if there is room in the device to hold another packet.
* If not, return a non-zero value to terminate the poll.
*/
if (kinetis_txringfull(priv))
{
return -EBUSY;
}
}
return -EBUSY;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -795,26 +795,23 @@ static int kinetis_txpoll(struct net_driver_s *dev)
if (priv->dev.d_len > 0)
{
if (!devif_loopback(&priv->dev))
kinetis_txdone(priv);
/* Send the packet */
kinetis_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if ((getreg32(priv->base + KINETIS_CAN_ESR2_OFFSET) &
(CAN_ESR2_IMB | CAN_ESR2_VPS)) ==
(CAN_ESR2_IMB | CAN_ESR2_VPS))
{
kinetis_txdone(priv);
/* Send the packet */
kinetis_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if ((getreg32(priv->base + KINETIS_CAN_ESR2_OFFSET) &
(CAN_ESR2_IMB | CAN_ESR2_VPS)) ==
(CAN_ESR2_IMB | CAN_ESR2_VPS))
if (kinetis_txringfull(priv))
{
if (kinetis_txringfull(priv))
{
return -EBUSY;
}
return -EBUSY;
}
}
}

View file

@ -1049,20 +1049,17 @@ static int lpc17can_txpoll(struct net_driver_s *dev)
if (priv->dev.d_len > 0)
{
if (!devif_loopback(&priv->dev))
/* Send the packet */
lpc17can_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (lpc17can_txringfull(priv))
{
/* Send the packet */
lpc17can_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (lpc17can_txringfull(priv))
{
return -EBUSY;
}
return -EBUSY;
}
}

View file

@ -712,57 +712,18 @@ static int lpc17_40_txpoll(struct net_driver_s *dev)
{
struct lpc17_40_driver_s *priv =
(struct lpc17_40_driver_s *)dev->d_private;
int ret = OK;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send this packet. In this context, we know that there is space
* for at least one more packet in the descriptor list.
*/
if (priv->lp_dev.d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
lpc17_40_transmit(priv);
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->lp_dev.d_flags))
#endif
{
arp_out(&priv->lp_dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->lp_dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->lp_dev))
{
/* Send this packet. In this context, we know that there is space
* for at least one more packet in the descriptor list.
*/
lpc17_40_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return any non-zero value to terminate the poll.
*/
ret = lpc17_40_txdesc(priv);
}
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
/* Check if there is room in the device to hold another packet. If
* not, return any non-zero value to terminate the poll.
*/
return ret;
return lpc17_40_txdesc(priv);
}
/****************************************************************************

View file

@ -1128,84 +1128,46 @@ static int lpc43_txpoll(struct net_driver_s *dev)
struct lpc43_ethmac_s *priv =
(struct lpc43_ethmac_s *)dev->d_private;
DEBUGASSERT(priv->dev.d_buf != NULL);
/* Send the packet */
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
lpc43_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
/* Check if the next TX descriptor is owned by the Ethernet DMA or
* CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission.
*
* In a race condition, ETH_TDES0_OWN may be cleared BUT still
* not available because lpc43_freeframe() has not yet run. If
* lpc43_freeframe() has run, the buffer1 pointer (tdes2) will be
* nullified (and inflight should be < CONFIG_LPC43_ETH_NTXDESC).
*/
if (priv->dev.d_len > 0)
if ((priv->txhead->tdes0 & ETH_TDES0_OWN) != 0 ||
priv->txhead->tdes2 != 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
lpc43_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
/* Check if the next TX descriptor is owned by the Ethernet DMA or
* CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission.
*
* In a race condition, ETH_TDES0_OWN may be cleared BUT still
* not available because lpc43_freeframe() has not yet run. If
* lpc43_freeframe() has run, the buffer1 pointer (tdes2) will be
* nullified (and inflight should be < CONFIG_LPC43_ETH_NTXDESC).
*/
if ((priv->txhead->tdes0 & ETH_TDES0_OWN) != 0 ||
priv->txhead->tdes2 != 0)
{
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
return -EBUSY;
}
/* We have the descriptor, we can continue the poll. Allocate a new
* buffer for the poll.
*/
dev->d_buf = lpc43_allocbuffer(priv);
/* We can't continue the poll if we have no buffers */
if (dev->d_buf == NULL)
{
/* Terminate the poll. */
return -ENOMEM;
}
}
return -EBUSY;
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
/* We have the descriptor, we can continue the poll. Allocate a new
* buffer for the poll.
*/
dev->d_buf = lpc43_allocbuffer(priv);
/* We can't continue the poll if we have no buffers */
if (dev->d_buf == NULL)
{
/* Terminate the poll. */
return -ENOMEM;
}
return 0;
}

View file

@ -757,81 +757,49 @@ static int lpc54_eth_txpoll(struct net_driver_s *dev)
DEBUGASSERT(dev->d_private != NULL && dev->d_buf != NULL);
priv = (struct lpc54_ethdriver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
chan = lpc54_eth_getring(priv);
txring = &priv->eth_txring[chan];
(txring->tr_buffers)[txring->tr_supply] =
(uint32_t *)priv->eth_dev.d_buf;
lpc54_eth_transmit(priv, chan);
txring0 = &priv->eth_txring[0];
#ifdef CONFIG_LPC54_ETH_MULTIQUEUE
txring1 = &priv->eth_txring[1];
/* We cannot perform the Tx poll now if all of the Tx descriptors
* for both channels are in-use.
*/
if (priv->eth_dev.d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->eth_dev.d_flags))
#endif
{
arp_out(&priv->eth_dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->eth_dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->eth_dev))
{
/* Send the packet */
chan = lpc54_eth_getring(priv);
txring = &priv->eth_txring[chan];
(txring->tr_buffers)[txring->tr_supply] =
(uint32_t *)priv->eth_dev.d_buf;
lpc54_eth_transmit(priv, chan);
txring0 = &priv->eth_txring[0];
#ifdef CONFIG_LPC54_ETH_MULTIQUEUE
txring1 = &priv->eth_txring[1];
/* We cannot perform the Tx poll now if all of the Tx descriptors
* for both channels are in-use.
*/
if (txring0->tr_inuse >= txring0->tr_ndesc ||
txring1->tr_inuse >= txring1->tr_ndesc)
if (txring0->tr_inuse >= txring0->tr_ndesc ||
txring1->tr_inuse >= txring1->tr_ndesc)
#else
/* We cannot continue the Tx poll now if all of the Tx descriptors
* for this channel 0 are in-use.
*/
/* We cannot continue the Tx poll now if all of the Tx descriptors
* for this channel 0 are in-use.
*/
if (txring0->tr_inuse >= txring0->tr_ndesc)
if (txring0->tr_inuse >= txring0->tr_ndesc)
#endif
{
/* Stop the poll.. no more Tx descriptors */
{
/* Stop the poll.. no more Tx descriptors */
return 1;
}
return 1;
}
/* There is a free descriptor in the ring, allocate a new Tx buffer
* to perform the poll.
*/
/* There is a free descriptor in the ring, allocate a new Tx buffer
* to perform the poll.
*/
priv->eth_dev.d_buf = (uint8_t *)lpc54_pktbuf_alloc(priv);
if (priv->eth_dev.d_buf == NULL)
{
/* Stop the poll.. no more packet buffers */
priv->eth_dev.d_buf = (uint8_t *)lpc54_pktbuf_alloc(priv);
if (priv->eth_dev.d_buf == NULL)
{
/* Stop the poll.. no more packet buffers */
return 1;
}
}
return 1;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -42,49 +42,24 @@ static void amebaz_netdev_notify_tx_done(struct amebaz_dev_s *priv)
static int amebaz_txpoll(struct net_driver_s *dev)
{
struct amebaz_dev_s *priv = (struct amebaz_dev_s *)dev->d_private;
if (priv->dev.d_len > 0)
net_lock();
if (!priv->curr)
{
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
net_lock();
if (!priv->curr)
{
net_unlock();
amebaz_netdev_notify_tx_done(priv);
return false;
}
DEBUGASSERT(priv->curr->tail == priv->dev.d_buf);
skb_put(priv->curr, priv->dev.d_len);
rltk_wlan_send_skb(priv->devnum, priv->curr);
priv->dev.d_buf = NULL;
priv->curr = NULL;
net_unlock();
NETDEV_TXPACKETS(&priv->dev);
amebaz_netdev_notify_tx_done(priv);
return true;
}
net_unlock();
amebaz_netdev_notify_tx_done(priv);
return false;
}
return false;
DEBUGASSERT(priv->curr->tail == priv->dev.d_buf);
skb_put(priv->curr, priv->dev.d_len);
rltk_wlan_send_skb(priv->devnum, priv->curr);
priv->dev.d_buf = NULL;
priv->curr = NULL;
net_unlock();
NETDEV_TXPACKETS(&priv->dev);
amebaz_netdev_notify_tx_done(priv);
return true;
}
static int amebaz_transmit(struct amebaz_dev_s *priv)

View file

@ -590,51 +590,19 @@ static int s32k1xx_txpoll(struct net_driver_s *dev)
struct s32k1xx_driver_s *priv =
(struct s32k1xx_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
s32k1xx_transmit(priv);
priv->dev.d_buf = (uint8_t *)
s32k1xx_swap32((uint32_t)priv->txdesc[priv->txhead].data);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (priv->dev.d_len > 0)
if (s32k1xx_txringfull(priv))
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
s32k1xx_transmit(priv);
priv->dev.d_buf = (uint8_t *)
s32k1xx_swap32((uint32_t)priv->txdesc[priv->txhead].data);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (s32k1xx_txringfull(priv))
{
return -EBUSY;
}
}
return -EBUSY;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -796,26 +796,23 @@ static int s32k1xx_txpoll(struct net_driver_s *dev)
if (priv->dev.d_len > 0)
{
if (!devif_loopback(&priv->dev))
s32k1xx_txdone(priv);
/* Send the packet */
s32k1xx_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if ((getreg32(priv->base + S32K1XX_CAN_ESR2_OFFSET) &
(CAN_ESR2_IMB | CAN_ESR2_VPS)) ==
(CAN_ESR2_IMB | CAN_ESR2_VPS))
{
s32k1xx_txdone(priv);
/* Send the packet */
s32k1xx_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if ((getreg32(priv->base + S32K1XX_CAN_ESR2_OFFSET) &
(CAN_ESR2_IMB | CAN_ESR2_VPS)) ==
(CAN_ESR2_IMB | CAN_ESR2_VPS))
if (s32k1xx_txringfull(priv))
{
if (s32k1xx_txringfull(priv))
{
return -EBUSY;
}
return -EBUSY;
}
}
}

View file

@ -796,77 +796,48 @@ static int s32k3xx_txpoll(struct net_driver_s *dev)
DEBUGASSERT(priv->dev.d_buf != NULL);
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
s32k3xx_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
/* Check if the next TX descriptor is owned by the Ethernet DMA or
* CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission.
*
* In a race condition, ETH_TDES3_OWN may be cleared BUT still
* not available because s32k3xx_freeframe() has not yet run. If
* s32k3xx_freeframe() has run, the buffer1 pointer (tdes2) will be
* nullified (and inflight should be < CONFIG_S32K3XX_ENET_NTXBUFFERS).
*/
if (priv->dev.d_len > 0)
if ((priv->txhead->des3 & EMAC_TDES3_OWN_MASK) != 0 ||
priv->txhead->des0 != 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
nerr("No tx descriptors available");
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
return -EBUSY;
}
/* Send the packet */
/* We have the descriptor, we can continue the poll. Allocate a new
* buffer for the poll.
*/
s32k3xx_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
dev->d_buf = s32k3xx_allocbuffer(priv);
/* Check if the next TX descriptor is owned by the Ethernet DMA or
* CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission.
*
* In a race condition, ETH_TDES3_OWN may be cleared BUT still
* not available because s32k3xx_freeframe() has not yet run. If
* s32k3xx_freeframe() has run, the buffer1 pointer (tdes2) will be
* nullified (and inflight should be < CONFIG_S32K3XX_ENET_NTXBUFFERS).
*/
/* We can't continue the poll if we have no buffers */
if ((priv->txhead->des3 & EMAC_TDES3_OWN_MASK) != 0 ||
priv->txhead->des0 != 0)
{
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
if (dev->d_buf == NULL)
{
/* Terminate the poll. */
nerr("No tx descriptors available");
nerr("No tx buffer available");
return -EBUSY;
}
/* We have the descriptor, we can continue the poll. Allocate a new
* buffer for the poll.
*/
dev->d_buf = s32k3xx_allocbuffer(priv);
/* We can't continue the poll if we have no buffers */
if (dev->d_buf == NULL)
{
/* Terminate the poll. */
nerr("No tx buffer available");
return -ENOMEM;
}
return -ENOMEM;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -961,26 +961,23 @@ static int s32k3xx_txpoll(struct net_driver_s *dev)
if (priv->dev.d_len > 0)
{
if (!devif_loopback(&priv->dev))
s32k3xx_txdone(priv);
/* Send the packet */
s32k3xx_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if ((getreg32(priv->base + S32K3XX_CAN_ESR2_OFFSET) &
(CAN_ESR2_IMB | CAN_ESR2_VPS)) ==
(CAN_ESR2_IMB | CAN_ESR2_VPS))
{
s32k3xx_txdone(priv);
/* Send the packet */
s32k3xx_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if ((getreg32(priv->base + S32K3XX_CAN_ESR2_OFFSET) &
(CAN_ESR2_IMB | CAN_ESR2_VPS)) ==
(CAN_ESR2_IMB | CAN_ESR2_VPS))
if (s32k3xx_txringfull(priv))
{
if (s32k3xx_txringfull(priv))
{
return -EBUSY;
}
return -EBUSY;
}
}
}

View file

@ -831,53 +831,21 @@ static int sam_txpoll(struct net_driver_s *dev)
{
struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
sam_transmit(priv);
/* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
if (priv->dev.d_len > 0)
if (sam_txfree(priv) == 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
sam_transmit(priv);
/* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
if (sam_txfree(priv) == 0)
{
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
return -EBUSY;
}
}
return -EBUSY;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -866,53 +866,21 @@ static int sam_txpoll(struct net_driver_s *dev)
{
struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
sam_transmit(priv);
/* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
if (priv->dev.d_len > 0)
if (sam_txfree(priv) == 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
sam_transmit(priv);
/* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
if (sam_txfree(priv) == 0)
{
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
return -EBUSY;
}
}
return -EBUSY;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -1179,53 +1179,21 @@ static int sam_txpoll(struct net_driver_s *dev)
{
struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
sam_transmit(priv);
/* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
if (priv->dev.d_len > 0)
if (sam_txfree(priv) == 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
sam_transmit(priv);
/* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
if (sam_txfree(priv) == 0)
{
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
return -EBUSY;
}
}
return -EBUSY;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -808,53 +808,21 @@ static int sam_txpoll(struct net_driver_s *dev)
{
struct sam_gmac_s *priv = (struct sam_gmac_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
sam_transmit(priv);
/* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
if (priv->dev.d_len > 0)
if (sam_txfree(priv) == 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
sam_transmit(priv);
/* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
if (sam_txfree(priv) == 0)
{
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
return -EBUSY;
}
}
return -EBUSY;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -796,53 +796,21 @@ static int sam_txpoll(struct net_driver_s *dev)
{
struct sam_gmac_s *priv = (struct sam_gmac_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
sam_transmit(priv);
/* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
if (priv->dev.d_len > 0)
if (sam_txfree(priv) == 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
sam_transmit(priv);
/* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
if (sam_txfree(priv) == 0)
{
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
return -EBUSY;
}
}
return -EBUSY;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -1470,53 +1470,21 @@ static int sam_txpoll(struct net_driver_s *dev)
{
struct sam_emac_s *priv = (struct sam_emac_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
sam_transmit(priv, EMAC_QUEUE_0);
/* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
if (priv->dev.d_len > 0)
if (sam_txfree(priv, EMAC_QUEUE_0) == 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
sam_transmit(priv, EMAC_QUEUE_0);
/* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
if (sam_txfree(priv, EMAC_QUEUE_0) == 0)
{
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
return -EBUSY;
}
}
return -EBUSY;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -1021,22 +1021,19 @@ static int stm32can_txpoll(struct net_driver_s *dev)
if (priv->dev.d_len > 0)
{
if (!devif_loopback(&priv->dev))
stm32can_txdone(priv);
/* Send the packet */
stm32can_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (stm32can_txready(priv) == false)
{
stm32can_txdone(priv);
/* Send the packet */
stm32can_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (stm32can_txready(priv) == false)
{
return -EBUSY;
}
return -EBUSY;
}
}

View file

@ -1246,76 +1246,44 @@ static int stm32_txpoll(struct net_driver_s *dev)
DEBUGASSERT(priv->dev.d_buf != NULL);
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
stm32_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
/* Check if the next TX descriptor is owned by the Ethernet DMA or
* CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission.
*
* In a race condition, ETH_TDES0_OWN may be cleared BUT still
* not available because stm32_freeframe() has not yet run. If
* stm32_freeframe() has run, the buffer1 pointer (tdes2) will be
* nullified (and inflight should be < CONFIG_STM32_ETH_NTXDESC).
*/
if (priv->dev.d_len > 0)
if ((priv->txhead->tdes0 & ETH_TDES0_OWN) != 0 ||
priv->txhead->tdes2 != 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
return -EBUSY;
}
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
/* We have the descriptor, we can continue the poll. Allocate a new
* buffer for the poll.
*/
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
dev->d_buf = stm32_allocbuffer(priv);
stm32_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
/* We can't continue the poll if we have no buffers */
/* Check if the next TX descriptor is owned by the Ethernet DMA or
* CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission.
*
* In a race condition, ETH_TDES0_OWN may be cleared BUT still
* not available because stm32_freeframe() has not yet run. If
* stm32_freeframe() has run, the buffer1 pointer (tdes2) will be
* nullified (and inflight should be < CONFIG_STM32_ETH_NTXDESC).
*/
if (dev->d_buf == NULL)
{
/* Terminate the poll. */
if ((priv->txhead->tdes0 & ETH_TDES0_OWN) != 0 ||
priv->txhead->tdes2 != 0)
{
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
return -EBUSY;
}
/* We have the descriptor, we can continue the poll. Allocate a new
* buffer for the poll.
*/
dev->d_buf = stm32_allocbuffer(priv);
/* We can't continue the poll if we have no buffers */
if (dev->d_buf == NULL)
{
/* Terminate the poll. */
return -ENOMEM;
}
}
return -ENOMEM;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -3045,22 +3045,19 @@ static int fdcan_txpoll(struct net_driver_s *dev)
if (priv->dev.d_len > 0)
{
if (!devif_loopback(&priv->dev))
fdcan_txdone(priv);
/* Send the packet */
fdcan_send(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (fdcan_txready(priv) == false)
{
fdcan_txdone(priv);
/* Send the packet */
fdcan_send(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (fdcan_txready(priv) == false)
{
return -EBUSY;
}
return -EBUSY;
}
}

View file

@ -1045,22 +1045,19 @@ static int stm32can_txpoll(struct net_driver_s *dev)
if (priv->dev.d_len > 0)
{
if (!devif_loopback(&priv->dev))
stm32can_txdone(priv);
/* Send the packet */
stm32can_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (stm32can_txready(priv) == false)
{
stm32can_txdone(priv);
/* Send the packet */
stm32can_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (stm32can_txready(priv) == false)
{
return -EBUSY;
}
return -EBUSY;
}
}

View file

@ -1288,76 +1288,44 @@ static int stm32_txpoll(struct net_driver_s *dev)
DEBUGASSERT(priv->dev.d_buf != NULL);
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
stm32_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
/* Check if the next TX descriptor is owned by the Ethernet DMA or
* CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission.
*
* In a race condition, ETH_TDES0_OWN may be cleared BUT still
* not available because stm32_freeframe() has not yet run. If
* stm32_freeframe() has run, the buffer1 pointer (tdes2) will be
* nullified (and inflight should be < CONFIG_STM32F7_ETH_NTXDESC).
*/
if (priv->dev.d_len > 0)
if ((priv->txhead->tdes0 & ETH_TDES0_OWN) != 0 ||
priv->txhead->tdes2 != 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
return -EBUSY;
}
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
/* We have the descriptor, we can continue the poll. Allocate a new
* buffer for the poll.
*/
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
dev->d_buf = stm32_allocbuffer(priv);
stm32_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
/* We can't continue the poll if we have no buffers */
/* Check if the next TX descriptor is owned by the Ethernet DMA or
* CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission.
*
* In a race condition, ETH_TDES0_OWN may be cleared BUT still
* not available because stm32_freeframe() has not yet run. If
* stm32_freeframe() has run, the buffer1 pointer (tdes2) will be
* nullified (and inflight should be < CONFIG_STM32F7_ETH_NTXDESC).
*/
if (dev->d_buf == NULL)
{
/* Terminate the poll. */
if ((priv->txhead->tdes0 & ETH_TDES0_OWN) != 0 ||
priv->txhead->tdes2 != 0)
{
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
return -EBUSY;
}
/* We have the descriptor, we can continue the poll. Allocate a new
* buffer for the poll.
*/
dev->d_buf = stm32_allocbuffer(priv);
/* We can't continue the poll if we have no buffers */
if (dev->d_buf == NULL)
{
/* Terminate the poll. */
return -ENOMEM;
}
}
return -ENOMEM;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -1323,77 +1323,48 @@ static int stm32_txpoll(struct net_driver_s *dev)
DEBUGASSERT(priv->dev.d_buf != NULL);
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
stm32_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
/* Check if the next TX descriptor is owned by the Ethernet DMA or
* CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission.
*
* In a race condition, ETH_TDES3_OWN may be cleared BUT still
* not available because stm32_freeframe() has not yet run. If
* stm32_freeframe() has run, the buffer1 pointer (tdes2) will be
* nullified (and inflight should be < CONFIG_STM32H7_ETH_NTXDESC).
*/
if (priv->dev.d_len > 0)
if ((priv->txhead->des3 & ETH_TDES3_RD_OWN) != 0 ||
priv->txhead->des0 != 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
nerr("No tx descriptors available");
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
return -EBUSY;
}
/* Send the packet */
/* We have the descriptor, we can continue the poll. Allocate a new
* buffer for the poll.
*/
stm32_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
dev->d_buf = stm32_allocbuffer(priv);
/* Check if the next TX descriptor is owned by the Ethernet DMA or
* CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission.
*
* In a race condition, ETH_TDES3_OWN may be cleared BUT still
* not available because stm32_freeframe() has not yet run. If
* stm32_freeframe() has run, the buffer1 pointer (tdes2) will be
* nullified (and inflight should be < CONFIG_STM32H7_ETH_NTXDESC).
*/
/* We can't continue the poll if we have no buffers */
if ((priv->txhead->des3 & ETH_TDES3_RD_OWN) != 0 ||
priv->txhead->des0 != 0)
{
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
if (dev->d_buf == NULL)
{
/* Terminate the poll. */
nerr("No tx descriptors available");
nerr("No tx buffer available");
return -EBUSY;
}
/* We have the descriptor, we can continue the poll. Allocate a new
* buffer for the poll.
*/
dev->d_buf = stm32_allocbuffer(priv);
/* We can't continue the poll if we have no buffers */
if (dev->d_buf == NULL)
{
/* Terminate the poll. */
nerr("No tx buffer available");
return -ENOMEM;
}
return -ENOMEM;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -934,20 +934,17 @@ static int fdcan_txpoll(struct net_driver_s *dev)
if (priv->dev.d_len > 0)
{
if (!devif_loopback(&priv->dev))
/* Send the packet */
fdcan_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (fdcan_txringfull(priv))
{
/* Send the packet */
fdcan_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (fdcan_txringfull(priv))
{
return -EBUSY;
}
return -EBUSY;
}
}

View file

@ -603,54 +603,12 @@ static int tiva_transmit(struct tiva_driver_s *priv)
static int tiva_txpoll(struct net_driver_s *dev)
{
struct tiva_driver_s *priv = (struct tiva_driver_s *)dev->d_private;
int ret = OK;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet. tiva_transmit() will return zero if the
* packet was successfully handled.
*/
ninfo("Poll result: d_len=%d\n", priv->ld_dev.d_len);
if (priv->ld_dev.d_len > 0)
{
DEBUGASSERT(!(tiva_ethin(priv, TIVA_MAC_TR_OFFSET) & MAC_TR_NEWTX));
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->ld_dev.d_flags))
#endif
{
arp_out(&priv->ld_dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->ld_dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->ld_dev))
{
/* Send the packet. tiva_transmit() will return zero if the
* packet was successfully handled.
*/
ret = tiva_transmit(priv);
}
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
*/
return ret;
return tiva_transmit(priv);
}
/****************************************************************************

View file

@ -1246,76 +1246,44 @@ static int tiva_txpoll(struct net_driver_s *dev)
DEBUGASSERT(priv->dev.d_buf != NULL);
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
tiva_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
/* Check if the next TX descriptor is owned by the Ethernet DMA or
* CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission.
*
* In a race condition, EMAC_TDES0_OWN may be cleared BUT still
* not available because tiva_freeframe() has not yet run. If
* tiva_freeframe() has run, the buffer1 pointer (tdes2) will be
* nullified (and inflight should be < CONFIG_TIVA_EMAC_NTXDESC).
*/
if (priv->dev.d_len > 0)
if ((priv->txhead->tdes0 & EMAC_TDES0_OWN) != 0 ||
priv->txhead->tdes2 != 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
return -EBUSY;
}
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
/* We have the descriptor, we can continue the poll. Allocate a new
* buffer for the poll.
*/
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
dev->d_buf = tiva_allocbuffer(priv);
tiva_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
/* We can't continue the poll if we have no buffers */
/* Check if the next TX descriptor is owned by the Ethernet DMA or
* CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission.
*
* In a race condition, EMAC_TDES0_OWN may be cleared BUT still
* not available because tiva_freeframe() has not yet run. If
* tiva_freeframe() has run, the buffer1 pointer (tdes2) will be
* nullified (and inflight should be < CONFIG_TIVA_EMAC_NTXDESC).
*/
if (dev->d_buf == NULL)
{
/* Terminate the poll. */
if ((priv->txhead->tdes0 & EMAC_TDES0_OWN) != 0 ||
priv->txhead->tdes2 != 0)
{
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
return -EBUSY;
}
/* We have the descriptor, we can continue the poll. Allocate a new
* buffer for the poll.
*/
dev->d_buf = tiva_allocbuffer(priv);
/* We can't continue the poll if we have no buffers */
if (dev->d_buf == NULL)
{
/* Terminate the poll. */
return -ENOMEM;
}
}
return -ENOMEM;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -199,45 +199,9 @@ static int emac_txpoll(struct net_driver_s *dev)
FAR struct emac_driver_s *priv =
(FAR struct emac_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
/* Send the packet */
if (priv->d_dev.d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->d_dev.d_flags))
#endif
{
arp_out(&priv->d_dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->d_dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->d_dev))
{
/* Send the packet */
emac_transmit(priv);
/* Check if there is room in the device to hold another packet.
* If not, return a non-zero value to terminate the poll.
*/
}
}
emac_transmit(priv);
/* If zero is returned, the polling will continue until all connections
* have been examined.

View file

@ -1119,76 +1119,43 @@ static int pic32mx_transmit(struct pic32mx_driver_s *priv)
static int pic32mx_txpoll(struct net_driver_s *dev)
{
struct pic32mx_driver_s *priv = (struct pic32mx_driver_s *)dev->d_private;
int ret = OK;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send this packet. In this context, we know that there is space
* for at least one more packet in the descriptor list.
*/
if (priv->pd_dev.d_len > 0)
pic32mx_transmit(priv);
/* Check if the next TX descriptor is available. If not, return a
* non-zero value to terminate the poll.
*/
if (pic32mx_txdesc(priv) == NULL)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
/* There are no more TX descriptors/buffers available..
* stop the poll
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->pd_dev.d_flags))
#endif
{
arp_out(&priv->pd_dev);
}
#endif /* CONFIG_NET_IPv4 */
return -EAGAIN;
}
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->pd_dev);
}
#endif /* CONFIG_NET_IPv6 */
/* Get the next Tx buffer needed in order to continue the poll */
if (!devif_loopback(&priv->pd_dev))
{
/* Send this packet. In this context, we know that there is space
* for at least one more packet in the descriptor list.
*/
priv->pd_dev.d_buf = pic32mx_allocbuffer(priv);
if (priv->pd_dev.d_buf == NULL)
{
/* We have no more buffers available for the nex Tx.. stop the
* poll
*/
pic32mx_transmit(priv);
/* Check if the next TX descriptor is available. If not, return a
* non-zero value to terminate the poll.
*/
if (pic32mx_txdesc(priv) == NULL)
{
/* There are no more TX descriptors/buffers available..
* stop the poll
*/
return -EAGAIN;
}
/* Get the next Tx buffer needed in order to continue the poll */
priv->pd_dev.d_buf = pic32mx_allocbuffer(priv);
if (priv->pd_dev.d_buf == NULL)
{
/* We have no more buffers available for the nex Tx.. stop the
* poll
*/
return -ENOMEM;
}
}
return -ENOMEM;
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
*/
return ret;
return 0;
}
/****************************************************************************

View file

@ -1221,76 +1221,43 @@ static int pic32mz_transmit(struct pic32mz_driver_s *priv)
static int pic32mz_txpoll(struct net_driver_s *dev)
{
struct pic32mz_driver_s *priv = (struct pic32mz_driver_s *)dev->d_private;
int ret = OK;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send this packet. In this context, we know that there is space
* for at least one more packet in the descriptor list.
*/
if (priv->pd_dev.d_len > 0)
pic32mz_transmit(priv);
/* Check if the next TX descriptor is available. If not, return a
* non-zero value to terminate the poll.
*/
if (pic32mz_txdesc(priv) == NULL)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
/* There are no more TX descriptors/buffers available..
* stop the poll
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->pd_dev.d_flags))
#endif
{
arp_out(&priv->pd_dev);
}
#endif /* CONFIG_NET_IPv4 */
return -EAGAIN;
}
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->pd_dev);
}
#endif /* CONFIG_NET_IPv6 */
/* Get the next Tx buffer needed in order to continue the poll */
if (!devif_loopback(&priv->pd_dev))
{
/* Send this packet. In this context, we know that there is space
* for at least one more packet in the descriptor list.
*/
priv->pd_dev.d_buf = pic32mz_allocbuffer(priv);
if (priv->pd_dev.d_buf == NULL)
{
/* We have no more buffers available for the next Tx..
* stop the poll
*/
pic32mz_transmit(priv);
/* Check if the next TX descriptor is available. If not, return a
* non-zero value to terminate the poll.
*/
if (pic32mz_txdesc(priv) == NULL)
{
/* There are no more TX descriptors/buffers available..
* stop the poll
*/
return -EAGAIN;
}
/* Get the next Tx buffer needed in order to continue the poll */
priv->pd_dev.d_buf = pic32mz_allocbuffer(priv);
if (priv->pd_dev.d_buf == NULL)
{
/* We have no more buffers available for the next Tx..
* stop the poll
*/
return -ENOMEM;
}
}
return -ENOMEM;
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
*/
return ret;
return 0;
}
/****************************************************************************

View file

@ -282,45 +282,9 @@ static int misoc_net_txpoll(struct net_driver_s *dev)
struct misoc_net_driver_s *priv =
(struct misoc_net_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
/* Send the packet */
if (priv->misoc_net_dev.d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->misoc_net_dev.d_flags))
#endif
{
arp_out(&priv->misoc_net_dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->misoc_net_dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->misoc_net_dev))
{
/* Send the packet */
misoc_net_transmit(priv);
/* Check if there is room in the device to hold another packet.
* If not, return a non-zero value to terminate the poll.
*/
}
}
misoc_net_transmit(priv);
/* If zero is returned, the polling will continue until all connections
* have been examined.

View file

@ -1047,76 +1047,44 @@ static int rx65n_txpoll(struct net_driver_s *dev)
DEBUGASSERT(priv->dev.d_buf != NULL);
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
rx65n_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
/* Check if the next TX descriptor is owned by the Ethernet DMA or
* CPU. We cannot perform the TX poll if we are unable to accept
* another packet fo transmission.
*
* In a race condition, TACT may be cleared BUT still not available
* because rx65n_freeframe() has not yet run. If rx65n_freeframe()
* has run, the buffer1 pointer (tdes2) will be nullified (and
* inflight should be CONFIG_RX65N_ETH_NTXDESC).
*/
if (priv->dev.d_len > 0)
if ((priv->txhead->tdes0 & TACT) != 0 ||
priv->txhead->tdes2 != 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
return -EBUSY;
}
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
/* We have the descriptor, we can continue the poll. Allocate a new
* buffer for the poll.
*/
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
dev->d_buf = rx65n_allocbuffer(priv);
rx65n_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
/* We can't continue the poll if we have no buffers */
/* Check if the next TX descriptor is owned by the Ethernet DMA or
* CPU. We cannot perform the TX poll if we are unable to accept
* another packet fo transmission.
*
* In a race condition, TACT may be cleared BUT still not available
* because rx65n_freeframe() has not yet run. If rx65n_freeframe()
* has run, the buffer1 pointer (tdes2) will be nullified (and
* inflight should be CONFIG_RX65N_ETH_NTXDESC).
*/
if (dev->d_buf == NULL)
{
/* Terminate the poll. */
if ((priv->txhead->tdes0 & TACT) != 0 ||
priv->txhead->tdes2 != 0)
{
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
return -EBUSY;
}
/* We have the descriptor, we can continue the poll. Allocate a new
* buffer for the poll.
*/
dev->d_buf = rx65n_allocbuffer(priv);
/* We can't continue the poll if we have no buffers */
if (dev->d_buf == NULL)
{
/* Terminate the poll. */
return -ENOMEM;
}
}
return -ENOMEM;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -372,63 +372,22 @@ static int bl602_net_txpoll(struct net_driver_s *dev)
struct bl602_net_driver_s *priv =
(struct bl602_net_driver_s *)dev->d_private;
if (priv->net_dev.d_len > 0)
{
DEBUGASSERT(priv->net_dev.d_buf);
/* Send the packet */
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
bl602_net_transmit(priv);
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->net_dev.d_flags))
#endif
{
arp_out(&priv->net_dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->net_dev);
}
#endif /* CONFIG_NET_IPv6 */
/* Check if the network is sending this packet to the IP address of
* this device. If so, just loop the packet back into the network but
* don't attempt to put it on the wire.
*/
if (!devif_loopback(&priv->net_dev))
{
/* Send the packet */
bl602_net_transmit(priv);
/* Check if there is room in the device to hold another packet.
* If not, return a non-zero value to terminate the poll.
*/
priv->net_dev.d_buf = bl602_netdev_alloc_txbuf();
if (priv->net_dev.d_buf)
{
priv->net_dev.d_buf += PRESERVE_80211_HEADER_LEN;
priv->net_dev.d_len = 0;
}
return priv->net_dev.d_buf == NULL;
}
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
/* Check if there is room in the device to hold another packet.
* If not, return a non-zero value to terminate the poll.
*/
return 0;
priv->net_dev.d_buf = bl602_netdev_alloc_txbuf();
if (priv->net_dev.d_buf)
{
priv->net_dev.d_buf += PRESERVE_80211_HEADER_LEN;
priv->net_dev.d_len = 0;
}
return priv->net_dev.d_buf == NULL;
}
/****************************************************************************

View file

@ -883,46 +883,17 @@ static int wlan_txpoll(struct net_driver_s *dev)
DEBUGASSERT(dev->d_buf != NULL);
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
wlan_cache_txpkt_tail(priv);
if (dev->d_len > 0)
pktbuf = wlan_alloc_buffer(priv);
if (pktbuf == NULL)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(dev->d_flags))
#endif
{
arp_out(dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(dev);
}
#endif /* CONFIG_NET_IPv6 */
wlan_cache_txpkt_tail(priv);
pktbuf = wlan_alloc_buffer(priv);
if (pktbuf == NULL)
{
return -ENOMEM;
}
dev->d_buf = pktbuf->buffer;
dev->d_len = WLAN_BUF_SIZE;
return -ENOMEM;
}
dev->d_buf = pktbuf->buffer;
dev->d_len = WLAN_BUF_SIZE;
/* If zero is returned, the polling will continue until
* all connections have been examined.
*/

View file

@ -319,41 +319,9 @@ static int litex_txpoll(struct net_driver_s *dev)
DEBUGASSERT(priv->dev.d_buf != NULL);
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
/* Send the packet */
if (priv->dev.d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
litex_transmit(priv);
}
}
litex_transmit(priv);
/* If zero is returned, the polling will continue until all connections
* have been examined.

View file

@ -1411,53 +1411,21 @@ static int mpfs_txpoll(struct net_driver_s *dev)
{
struct mpfs_ethmac_s *priv = (struct mpfs_ethmac_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
mpfs_transmit(priv, 0);
/* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
if (priv->dev.d_len > 0)
if (mpfs_txfree(priv, 0) == 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
mpfs_transmit(priv, 0);
/* Check if there are any free TX descriptors. We cannot perform
* the TX poll if we do not have buffering for another packet.
*/
if (mpfs_txfree(priv, 0) == 0)
{
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
return -EBUSY;
}
}
return -EBUSY;
}
/* If zero is returned, the polling will continue until all connections

View file

@ -260,54 +260,11 @@ static int netdriver_txpoll(struct net_driver_s *dev)
UNUSED(devidx);
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
/* Send the packet */
if (dev->d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(dev->d_flags))
#endif
{
arp_out(dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(dev))
{
/* Send the packet */
NETDEV_TXPACKETS(dev);
sim_netdev_send(devidx, dev->d_buf, dev->d_len);
NETDEV_TXDONE(dev);
}
else
{
/* Calling txdone callback after loopback. NETDEV_TXDONE macro is
* already called in devif_loopback.
*
* TODO: Maybe a unified interface with txdone callback registered
* is needed, then we can let devif_loopback call this callback.
*/
netdriver_txdone_interrupt(dev);
}
}
NETDEV_TXPACKETS(dev);
sim_netdev_send(devidx, dev->d_buf, dev->d_len);
NETDEV_TXDONE(dev);
/* If zero is returned, the polling will continue until all connections
* have been examined.

View file

@ -1583,67 +1583,33 @@ static int emac_txpoll(struct net_driver_s *dev)
DEBUGASSERT(priv->dev.d_buf != NULL);
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value == 0.
/* Send the packet */
emac_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
/* Check if the current TX descriptor is owned by the Ethernet DMA
* or CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission.
*/
if (priv->dev.d_len == 0)
if (TX_IS_BUSY(priv))
{
return 0;
}
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
emac_transmit(priv);
DEBUGASSERT(dev->d_len == 0 && dev->d_buf == NULL);
/* Check if the current TX descriptor is owned by the Ethernet DMA
* or CPU. We cannot perform the TX poll if we are unable to accept
* another packet for transmission.
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
if (TX_IS_BUSY(priv))
{
/* We have to terminate the poll if we have no more descriptors
* available for another transfer.
*/
return -EBUSY;
}
dev->d_buf = (uint8_t *)emac_alloc_buffer(priv);
if (dev->d_buf == NULL)
{
return -ENOMEM;
}
dev->d_len = EMAC_BUF_LEN;
return -EBUSY;
}
dev->d_buf = (uint8_t *)emac_alloc_buffer(priv);
if (dev->d_buf == NULL)
{
return -ENOMEM;
}
dev->d_len = EMAC_BUF_LEN;
/* If zero is returned, the polling will continue until all connections
* have been examined.
*/

View file

@ -880,46 +880,17 @@ static int wlan_txpoll(struct net_driver_s *dev)
DEBUGASSERT(dev->d_buf != NULL);
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
wlan_cache_txpkt_tail(priv);
if (dev->d_len > 0)
pktbuf = wlan_alloc_buffer(priv);
if (!pktbuf)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(dev->d_flags))
#endif
{
arp_out(dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(dev);
}
#endif /* CONFIG_NET_IPv6 */
wlan_cache_txpkt_tail(priv);
pktbuf = wlan_alloc_buffer(priv);
if (!pktbuf)
{
return -ENOMEM;
}
dev->d_buf = pktbuf->buffer;
dev->d_len = WLAN_BUF_SIZE;
return -ENOMEM;
}
dev->d_buf = pktbuf->buffer;
dev->d_len = WLAN_BUF_SIZE;
/* If zero is returned, the polling will continue until
* all connections have been examined.
*/

View file

@ -1151,52 +1151,12 @@ static int ez80emac_txpoll(FAR struct net_driver_s *dev)
{
FAR struct ez80emac_driver_s *priv =
(FAR struct ez80emac_driver_s *)dev->d_private;
int ret = 0;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet. ez80emac_transmit() will return zero if the
* packet was successfully handled.
*/
ninfo("Poll result: d_len=%d\n", priv->dev.d_len);
if (priv->dev.d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet. ez80emac_transmit() will return zero if the
* packet was successfully handled.
*/
ret = ez80emac_transmit(priv);
}
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
*/
return ret;
return ez80emac_transmit(priv);
}
/****************************************************************************

View file

@ -782,58 +782,22 @@ static int dm9x_txpoll(FAR struct net_driver_s *dev)
FAR struct dm9x_driver_s *priv =
(FAR struct dm9x_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
dm9x_transmit(priv);
/* Check if there is room in the DM90x0 to hold another packet.
* In 100M mode, that can be 2 packets, otherwise it is a single
* packet.
*/
if (priv->dm_dev.d_len > 0)
if (priv->dm_ntxpending > 1 || !priv->dm_b100m)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
/* Returning a non-zero value terminate the poll operation */
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dm_dev.d_flags))
#endif
{
arp_out(&priv->dm_dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dm_dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dm_dev))
{
/* Send the packet */
dm9x_transmit(priv);
/* Check if there is room in the DM90x0 to hold another packet.
* In 100M mode, that can be 2 packets, otherwise it is a single
* packet.
*/
if (priv->dm_ntxpending > 1 || !priv->dm_b100m)
{
/* Returning a non-zero value terminate the poll operation */
return 1;
}
}
return 1;
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
*/
return 0;
}

View file

@ -1175,52 +1175,13 @@ static int enc_txpoll(struct net_driver_s *dev)
{
FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
/* Send the packet */
ninfo("Poll result: d_len=%d\n", priv->dev.d_len);
if (priv->dev.d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
enc_transmit(priv);
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
/* Stop the poll now because we can queue only one packet */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
enc_transmit(priv);
/* Stop the poll now because we can queue only one packet */
return -EBUSY;
}
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
*/
return OK;
return -EBUSY;
}
/****************************************************************************

View file

@ -1146,51 +1146,8 @@ static int enc_txenqueue(FAR struct enc_driver_s *priv)
static int enc_txpoll(struct net_driver_s *dev)
{
FAR struct enc_driver_s *priv = (FAR struct enc_driver_s *)dev->d_private;
int ret = OK;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
ninfo("Poll result: d_len=%d\n", priv->dev.d_len);
if (priv->dev.d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
ret = enc_txenqueue(priv);
}
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
*/
return ret;
return enc_txenqueue(priv);
}
/****************************************************************************

View file

@ -345,45 +345,9 @@ static int ftmac100_txpoll(struct net_driver_s *dev)
FAR struct ftmac100_driver_s *priv =
(FAR struct ftmac100_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
/* Send the packet */
if (priv->ft_dev.d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->ft_dev.d_flags))
#endif
{
arp_out(&priv->ft_dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->ft_dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->ft_dev))
{
/* Send the packet */
ftmac100_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
}
}
ftmac100_transmit(priv);
/* If zero is returned, the polling will continue until all connections
* have been examined.

View file

@ -496,49 +496,15 @@ static int lan91c111_txpoll(FAR struct net_driver_s *dev)
{
FAR struct lan91c111_driver_s *priv = dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
lan91c111_transmit(dev);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (dev->d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
if (IFF_IS_IPv4(dev->d_flags))
{
arp_out(dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv6(dev->d_flags))
{
neighbor_out(dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(dev))
{
/* Send the packet */
lan91c111_transmit(dev);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
return !(getreg16(priv, MIR_REG) & MIR_FREE_MASK);
}
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
*/
return 0;
return !(getreg16(priv, MIR_REG) & MIR_FREE_MASK);
}
/****************************************************************************

View file

@ -255,56 +255,22 @@ static int net_rpmsg_drv_txpoll(FAR struct net_driver_s *dev)
FAR struct net_rpmsg_drv_s *priv = dev->d_private;
uint32_t size;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
net_rpmsg_drv_transmit(dev, true);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (dev->d_len > 0)
dev->d_buf = rpmsg_get_tx_payload_buffer(&priv->ept, &size, false);
if (dev->d_buf)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
if (IFF_IS_IPv4(dev->d_flags))
{
arp_out(dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv6(dev->d_flags))
{
neighbor_out(dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(dev))
{
/* Send the packet */
net_rpmsg_drv_transmit(dev, true);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
dev->d_buf = rpmsg_get_tx_payload_buffer(&priv->ept, &size, false);
if (dev->d_buf)
{
dev->d_buf += sizeof(struct net_rpmsg_transfer_s);
dev->d_pktsize = size - sizeof(struct net_rpmsg_transfer_s);
}
return dev->d_buf == NULL;
}
dev->d_buf += sizeof(struct net_rpmsg_transfer_s);
dev->d_pktsize = size - sizeof(struct net_rpmsg_transfer_s);
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
*/
return 0;
return dev->d_buf == NULL;
}
/****************************************************************************

View file

@ -255,50 +255,9 @@ static int skel_txpoll(FAR struct net_driver_s *dev)
FAR struct skel_driver_s *priv =
(FAR struct skel_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
/* Send the packet */
if (priv->sk_dev.d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->sk_dev.d_flags))
#endif
{
arp_out(&priv->sk_dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->sk_dev);
}
#endif /* CONFIG_NET_IPv6 */
/* Check if the network is sending this packet to the IP address of
* this device. If so, just loop the packet back into the network but
* don't attempt to put it on the wire.
*/
if (!devif_loopback(&priv->sk_dev))
{
/* Send the packet */
skel_transmit(priv);
/* Check if there is room in the device to hold another packet.
* If not, return a non-zero value to terminate the poll.
*/
}
}
skel_transmit(priv);
/* If zero is returned, the polling will continue until all connections
* have been examined.

View file

@ -355,17 +355,7 @@ static int slip_txpoll(FAR struct net_driver_s *dev)
FAR struct slip_driver_s *priv =
(FAR struct slip_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
if (priv->dev.d_len > 0)
{
if (!devif_loopback(&priv->dev))
{
slip_transmit(priv);
}
}
slip_transmit(priv);
/* If zero is returned, the polling will continue until all connections
* have been examined.

View file

@ -358,46 +358,12 @@ static int tun_txpoll_tap(FAR struct net_driver_s *dev)
{
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
/* Send the packet */
if (priv->dev.d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
priv->read_d_len = priv->dev.d_len;
tun_fd_transmit(priv);
#ifdef CONFIG_NET_IPv4
if (IFF_IS_IPv4(priv->dev.d_flags))
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv6(priv->dev.d_flags))
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(dev))
{
/* Send the packet */
priv->read_d_len = priv->dev.d_len;
tun_fd_transmit(priv);
return 1;
}
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
*/
return 0;
return 1;
}
#endif
@ -430,28 +396,10 @@ static int tun_txpoll_tun(FAR struct net_driver_s *dev)
{
FAR struct tun_device_s *priv = (FAR struct tun_device_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
priv->read_d_len = priv->dev.d_len;
tun_fd_transmit(priv);
if (priv->dev.d_len > 0)
{
if (!devif_loopback(dev))
{
/* Send the packet */
priv->read_d_len = priv->dev.d_len;
tun_fd_transmit(priv);
return 1;
}
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
*/
return 0;
return 1;
}
/****************************************************************************

View file

@ -1186,57 +1186,15 @@ static int w5500_txpoll(FAR struct net_driver_s *dev)
FAR struct w5500_driver_s *self =
(FAR struct w5500_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
w5500_transmit(self);
/* Check if there is room in the device to hold another packet.
* If not, return a non-zero value to terminate the poll.
*/
if (self->w_dev.d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
if (IFF_IS_IPv4(self->w_dev.d_flags))
{
arp_out(&self->w_dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv6(self->w_dev.d_flags))
{
neighbor_out(&self->w_dev);
}
#endif /* CONFIG_NET_IPv6 */
/* Check if the network is sending this packet to the IP address of
* this device. If so, just loop the packet back into the network but
* don't attempt to put it on the wire.
*/
if (!devif_loopback(&self->w_dev))
{
/* Send the packet */
w5500_transmit(self);
/* Check if there is room in the device to hold another packet.
* If not, return a non-zero value to terminate the poll.
*/
if (!w5500_txbuf_numfree(self))
{
return -EBUSY;
}
}
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
*/
return OK;
return !w5500_txbuf_numfree(self);
}
/****************************************************************************

View file

@ -340,53 +340,15 @@ static int cdcecm_txpoll(FAR struct net_driver_s *dev)
FAR struct cdcecm_driver_s *priv =
(FAR struct cdcecm_driver_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
cdcecm_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
if (priv->dev.d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->dev.d_flags))
#endif
{
arp_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->dev))
{
/* Send the packet */
cdcecm_transmit(priv);
/* Check if there is room in the device to hold another packet. If
* not, return a non-zero value to terminate the poll.
*/
return 1;
}
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
*/
return 0;
return 1;
}
/****************************************************************************

View file

@ -983,53 +983,13 @@ static void rndis_rxdispatch(FAR void *arg)
static int rndis_txpoll(FAR struct net_driver_s *dev)
{
FAR struct rndis_dev_s *priv = (FAR struct rndis_dev_s *)dev->d_private;
int ret = OK;
if (!priv->connected)
{
return -EBUSY;
}
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
ninfo("Poll result: d_len=%d\n", priv->netdev.d_len);
if (priv->netdev.d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->netdev.d_flags))
#endif
{
arp_out(&priv->netdev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->netdev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->netdev))
{
ret = rndis_transmit(priv);
}
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
*/
return ret;
return rndis_transmit(priv);
}
/****************************************************************************

View file

@ -2277,15 +2277,9 @@ static int cdcmbim_txpoll(struct net_driver_s *dev)
nxmutex_lock(&priv->lock);
if (priv->netdev.d_len > 0)
{
if (!devif_loopback(&priv->netdev))
{
/* Send the packet */
/* Send the packet */
cdcmbim_transmit(priv);
}
}
cdcmbim_transmit(priv);
nxmutex_unlock(&priv->lock);

View file

@ -436,54 +436,16 @@ static int bcmf_txpoll(FAR struct net_driver_s *dev)
{
FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)dev->d_private;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
/* Send the packet */
bcmf_transmit(priv, priv->cur_tx_frame);
/* TODO: Check if there is room in the device to hold another
* packet. If not, return a non-zero value to terminate the poll.
*/
if (priv->bc_dev.d_len > 0)
{
/* Look up the destination MAC address and add it to the Ethernet
* header.
*/
#ifdef CONFIG_NET_IPv4
#ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(priv->bc_dev.d_flags))
#endif
{
arp_out(&priv->bc_dev);
}
#endif /* CONFIG_NET_IPv4 */
#ifdef CONFIG_NET_IPv6
#ifdef CONFIG_NET_IPv4
else
#endif
{
neighbor_out(&priv->bc_dev);
}
#endif /* CONFIG_NET_IPv6 */
if (!devif_loopback(&priv->bc_dev))
{
/* Send the packet */
bcmf_transmit(priv, priv->cur_tx_frame);
/* TODO: Check if there is room in the device to hold another
* packet. If not, return a non-zero value to terminate the poll.
*/
priv->cur_tx_frame = NULL;
return 1;
}
}
/* If zero is returned, the polling will continue until all connections
* have been examined.
*/
return 0;
priv->cur_tx_frame = NULL;
return 1;
}
/****************************************************************************

View file

@ -594,23 +594,6 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback);
void neighbor_out(FAR struct net_driver_s *dev);
#endif /* CONFIG_NET_IPv6 */
/****************************************************************************
* Name: devif_loopback
*
* Description:
* This function should be called before sending out a packet. The function
* checks the destination address of the packet to see whether the target
* of packet is ourself and then consume the packet directly by calling
* input process functions.
*
* Returned Value:
* Zero is returned if the packet don't loop back to ourself, otherwise
* a non-zero value is returned.
*
****************************************************************************/
int devif_loopback(FAR struct net_driver_s *dev);
/****************************************************************************
* Name: netdev_ifup / netdev_ifdown
*

View file

@ -528,6 +528,23 @@ void devif_can_send(FAR struct net_driver_s *dev, FAR const void *buf,
int devif_out(FAR struct net_driver_s *dev, devif_poll_callback_t callback);
/****************************************************************************
* Name: devif_loopback
*
* Description:
* This function should be called before sending out a packet. The function
* checks the destination address of the packet to see whether the target
* of packet is ourself and then consume the packet directly by calling
* input process functions.
*
* Returned Value:
* Zero is returned if the packet don't loop back to ourself, otherwise
* a non-zero value is returned.
*
****************************************************************************/
int devif_loopback(FAR struct net_driver_s *dev);
#undef EXTERN
#ifdef __cplusplus
}

View file

@ -31,6 +31,7 @@
#include <nuttx/net/netconfig.h>
#include <nuttx/net/netdev.h>
#include <nuttx/net/net.h>
#include <nuttx/net/arp.h>
#include "devif/devif.h"
#include "arp/arp.h"
@ -785,11 +786,43 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback)
int devif_out(FAR struct net_driver_s *dev, devif_poll_callback_t callback)
{
int bstop;
if (dev->d_len == 0)
{
return 0;
}
bstop = devif_loopback(dev);
if (bstop)
{
return bstop;
}
#ifdef CONFIG_NET_ETHERNET
if (dev->d_lltype == NET_LL_ETHERNET ||
dev->d_lltype == NET_LL_IEEE80211)
{
# ifdef CONFIG_NET_IPv4
# ifdef CONFIG_NET_IPv6
if (IFF_IS_IPv4(dev->d_flags))
# endif /* CONFIG_NET_IPv6 */
{
arp_out(dev);
}
# endif /* CONFIG_NET_IPv4 */
# ifdef CONFIG_NET_IPv6
# ifdef CONFIG_NET_IPv4
else
# endif /* CONFIG_NET_IPv4 */
{
neighbor_out(dev);
}
# endif /* CONFIG_NET_IPv6 */
}
#endif /* CONFIG_NET_ETHERNET */
return callback(dev);
}