anchao commented on code in PR #7616: URL: https://github.com/apache/nuttx/pull/7616#discussion_r1038340165
########## include/nuttx/net/netdev.h: ########## @@ -802,4 +923,88 @@ void net_incr32(FAR uint8_t *op32, uint16_t op16); int netdev_lladdrsize(FAR struct net_driver_s *dev); +/**************************************************************************** + * Name: netdev_iob_prepare + * + * Description: + * Prepare data buffer for a given NIC + * The iob offset will be updated to l2 gruard size by default: + * ---------------------------------------------------------------- + * | iob entry | + * ---------------------------------------------------------------| + * |<--- CONFIG_NET_LL_GUARDSIZE -->|<--- io_len/io_pktlen(0) --->| + * ---------------------------------------------------------------| + * + * Assumptions: + * The caller has locked the network. + * + * Returned Value: + * A non-zero copy is returned on success. + * + ****************************************************************************/ + +int netdev_iob_prepare(FAR struct net_driver_s *dev, bool throttled, + unsigned int timeout); + +/**************************************************************************** + * Name: netdev_iob_clear + * + * Description: + * Clean up buffer resources for a given NIC + * + * Assumptions: + * The caller has locked the network and dev->d_iob has been + * released or taken away. + * + ****************************************************************************/ + +void netdev_iob_clear(FAR struct net_driver_s *dev); + +/**************************************************************************** + * Name: netdev_iob_release + * + * Description: + * Release buffer resources for a given NIC + * + * Assumptions: + * The caller has locked the network. + * + ****************************************************************************/ + +void netdev_iob_release(FAR struct net_driver_s *dev); + +/**************************************************************************** + * Name: netdev_input + * + * Description: + * This function will copy the flat buffer that does not support + * Scatter/gather to the iob vector buffer. + * + * Compatible with all old flat buffer NICs: + * + * [tcp|udp|icmp|...]ipv[4|6]_data_handler() + * | (iob_concat/append to readahead) + * | + * pkt/ipv[4/6]_in()/... + * | + * | + * netdev_input() // new interface, Scatter/gather flat/iobs + * | + * | + * pkt/ipv[4|6]_input()/... + * | + * | + * NICs io vector receive(Orignal flat buffer) + * + * Input Parameters: + * callback - Input callback of L3 stack + * + * Returned Value: + * A non-zero copy is returned on success. + * + ****************************************************************************/ + +int netdev_input(FAR struct net_driver_s *dev, Review Comment: Done ########## include/nuttx/net/netdev.h: ########## @@ -560,10 +573,69 @@ int sixlowpan_input(FAR struct radio_driver_s *ieee, * return 0; * } * + * Compatible with all old flat buffer NICs + * + * tcp_poll()/udp_poll()/pkt_poll()/...(l3/l4) + * / \ + * / \ + * devif_poll_[l3/l4]_connections() devif_iob_send() (nocopy:udp/icmp/..) + * / \ (copy:tcp) + * / \ + * devif_iob_poll(devif_poll_callback()) devif_poll_callback() + * / \ + * / \ + * devif_poll("NIC"_txpoll) "NIC"_send()(dev->d_buf) + * ****************************************************************************/ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback); +/**************************************************************************** + * 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 -- 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