anchao commented on code in PR #7616: URL: https://github.com/apache/incubator-nuttx/pull/7616#discussion_r1027227824
########## net/devif/devif_poll.c: ########## @@ -616,12 +616,71 @@ static inline int devif_poll_tcp_connections(FAR struct net_driver_s *dev, # define devif_poll_tcp_connections(dev, callback) (0) #endif +/**************************************************************************** + * 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) +{ + FAR struct iob_s *iob; + uint16_t llhdrlen; + int bstop = false; + + if (dev->d_len > 0 && dev->d_iob != NULL) + { + llhdrlen = NET_LL_HDRLEN(dev); + + /* Copy iob to flat buffer */ + + iob_copyout(dev->d_pollbuf + llhdrlen, dev->d_iob, dev->d_len, 0); + + /* Copy l2 header (arp out) */ + + memcpy(dev->d_pollbuf, + dev->d_iob->io_data + (CONFIG_NET_LL_GRUARDSIZE - llhdrlen), + llhdrlen); + + /* Save iob buffer and restore flat buffer pointer */ + + iob = dev->d_iob; + dev->d_iob = NULL; + dev->d_buf = dev->d_pollbuf; + + /* Call the real device callback */ + + bstop = dev->d_pollcallback(dev); + if (bstop) + { + /* Polling stop, release iob buffer */ + + iob_free_chain(iob); + dev->d_buf = NULL; + } + else + { + /* Continue polling, restore iob */ + + dev->d_iob = iob; + dev->d_buf = (FAR void *)ETHBUF; Review Comment: Yes, ETHBUF will be cast to (struct eth_hdr_s), and the type of d_buf is (uint8_t *) ``` FAR uint8_t *d_buf; #define ETHBUF ((FAR struct eth_hdr_s *) \ (dev->d_iob ? \ &dev->d_iob->io_data[CONFIG_NET_LL_GRUARDSIZE - NET_LL_HDRLEN(dev)] : \ dev->d_buf)) ``` -- 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