devif_poll: only call the corresponding xxx_poll when there is data to be sent

reduce the execution consumption of irrelevant code

testing the TX rates of TCP and UDP based on the Infineon board can
increase them by 13%.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu
2025-11-05 17:47:10 +08:00
committed by Xiang Xiao
parent a0b847bf1b
commit c481374fb8
38 changed files with 241 additions and 214 deletions
+13 -8
View File
@@ -310,8 +310,9 @@ FAR struct net_driver_s *netdev_default(void);
* data is available.
*
* Input Parameters:
* lipaddr - The local address bound to the socket
* ripaddr - The remote address to send the data
* lipaddr - The local address bound to the socket
* ripaddr - The remote address to send the data
* polltype - The type of poll to be triggered for the device.
*
* Returned Value:
* None
@@ -319,7 +320,8 @@ FAR struct net_driver_s *netdev_default(void);
****************************************************************************/
#ifdef CONFIG_NET_IPv4
void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr);
void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr,
uint32_t polltype);
#endif /* CONFIG_NET_IPv4 */
/****************************************************************************
@@ -330,8 +332,9 @@ void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr);
* data is available.
*
* Input Parameters:
* lipaddr - The local address bound to the socket
* ripaddr - The remote address to send the data
* lipaddr - The local address bound to the socket
* ripaddr - The remote address to send the data
* polltype - The type of poll to be triggered for the device.
*
* Returned Value:
* None
@@ -340,7 +343,8 @@ void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr);
#ifdef CONFIG_NET_IPv6
void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
FAR const net_ipv6addr_t ripaddr);
FAR const net_ipv6addr_t ripaddr,
uint32_t polltype);
#endif /* CONFIG_NET_IPv6 */
/****************************************************************************
@@ -352,14 +356,15 @@ void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
* packet will be routed.
*
* Input Parameters:
* dev - The network device driver state structure.
* dev - The network device driver state structure.
* polltype - The type of poll to be triggered for the device.
*
* Returned Value:
* None
*
****************************************************************************/
void netdev_txnotify_dev(FAR struct net_driver_s *dev);
void netdev_txnotify_dev(FAR struct net_driver_s *dev, uint32_t polltype);
/****************************************************************************
* Name: netdev_count
+2
View File
@@ -425,6 +425,8 @@ int netdev_register(FAR struct net_driver_s *dev, enum net_lltype_e lltype)
dev->d_conncb_tail = NULL;
dev->d_devcb = NULL;
dev->d_polltype = 0;
nxrmutex_init(&dev->d_lock);
/* We need exclusive access for the following operations */
+11 -5
View File
@@ -57,11 +57,12 @@
****************************************************************************/
#ifdef CONFIG_NET_IPv4
void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr)
void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr,
uint32_t polltype)
{
/* Find the device driver that serves the subnet of the remote address */
netdev_txnotify_dev(netdev_findby_ripv4addr(lipaddr, ripaddr));
netdev_txnotify_dev(netdev_findby_ripv4addr(lipaddr, ripaddr), polltype);
}
#endif /* CONFIG_NET_IPv4 */
@@ -83,11 +84,12 @@ void netdev_ipv4_txnotify(in_addr_t lipaddr, in_addr_t ripaddr)
#ifdef CONFIG_NET_IPv6
void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
FAR const net_ipv6addr_t ripaddr)
FAR const net_ipv6addr_t ripaddr,
uint32_t polltype)
{
/* Find the device driver that serves the subnet of the remote address */
netdev_txnotify_dev(netdev_findby_ripv6addr(lipaddr, ripaddr));
netdev_txnotify_dev(netdev_findby_ripv6addr(lipaddr, ripaddr), polltype);
}
#endif /* CONFIG_NET_IPv6 */
@@ -107,10 +109,14 @@ void netdev_ipv6_txnotify(FAR const net_ipv6addr_t lipaddr,
*
****************************************************************************/
void netdev_txnotify_dev(FAR struct net_driver_s *dev)
void netdev_txnotify_dev(FAR struct net_driver_s *dev, uint32_t polltype)
{
if (dev != NULL && dev->d_txavail != NULL)
{
/* Set the poll type flags */
dev->d_polltype |= polltype;
/* Notify the device driver that new TX data is available. */
dev->d_txavail(dev);