anchao commented on code in PR #7616: URL: https://github.com/apache/nuttx/pull/7616#discussion_r1038341235
########## net/devif/devif_poll.c: ########## @@ -772,6 +769,217 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback) return bstop; } +/**************************************************************************** + * Name: devif_poll_callback + * + * Description: + * This function will help us to gather multiple iob memory slices into a + * linear device buffer. if devices with small memory, this function will + * trigger a memory copy if net device start transmit the iob slices to + * flat buffer + * + ****************************************************************************/ + +static int devif_poll_callback(FAR struct net_driver_s *dev) +{ + if (dev->d_len > 0) + { + return true; + } + + return false; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: devif_iob_poll + * + * Description: + * This function will traverse each active network connection structure and + * will perform network polling operations. devif_poll() may be called + * asynchronously with the network driver can accept another outgoing + * packet. + * + * This function will call the provided callback function for every active + * connection. Polling will continue until all connections have been polled + * or until the user-supplied function returns a non-zero value (which it + * should do only if it cannot accept further write data). + * + * When the callback function is called, there may be an outbound packet + * waiting for service in the device packet buffer, and if so the d_len + * field is set to a value larger than zero. The device driver should then + * send out the packet. + * + * This is the iob buffer version of devif_input(), + * this function will support send/receive iob vectors directly between + * the driver and l3/l4 stack to avoid unnecessary memory copies, + * especially on hardware that supports Scatter/gather, which can + * greatly improve performance + * this function will uses d_iob as packets input which used by some + * NICs such as celluler net driver. + * + * If NIC hardware support Scatter/gather transfer + * + * tcp_poll()/udp_poll()/pkt_poll()/...(l3/l4) + * / \ + * / \ + * devif_poll_[l3|l4]_connections() devif_iob_send() (nocopy:udp/icmp/...) + * / \ (copy:tcp) + * / \ + * devif_iob_poll("NIC"_txpoll) callback() // "NIC"_txpoll + * + * + * Assumptions: + * This function is called from the MAC device driver with the network + * locked. + * + ****************************************************************************/ + +int devif_iob_poll(FAR struct net_driver_s *dev, Review Comment: Done ########## drivers/net/loopback.c: ########## @@ -200,7 +199,7 @@ static void lo_txavail_work(FAR void *arg) * return stop */ - while (devif_poll(&priv->lo_dev, NULL)); + while (devif_iob_poll(&priv->lo_dev, NULL)); Review Comment: Done -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org