luojun1234 commented on PR #6834: URL: https://github.com/apache/incubator-nuttx/pull/6834#issuecomment-1212007295
> IOB is shared mechanism used for different stacks. So on a multi-stack system where `CONFIG_IOB_HEADSIZE>0` all stacks are affected, maybe this is even a design limitation of the current IOB design. And could use some refactoring/redesign. > > But for the moment isn't there any way to introduce user storage for iob without affecting all the iob's? A rough idea from my side would just be using an union exclusively for the TCP side and not affect the others i.e. And just the pointer when using it in the TCP stack > > ``` > union iob_s_tcp_playload{ > uint_ptr user; > uint8_t io_data[CONFIG_IOB_BUFSIZE-sizeof(uint_ptr)]; > } iob_s_tcp_playload; > > struct iob_s incoming_data; > > // Fetch iob > > iob_s_tcp_playload* tcp_iob = (iob_s_tcp_playload*)(&incoming_data.io_data); > > struct custom_struct = (struct custom_struct*)tcp_iob.user; > memcpy(dst, &tcp_io.iodata[0], sizeof(iob_s_tcp_playload.io_data)); > ``` > > If you guys could share the TCP changes that need this I can give better input on this dicussion, or maybe include this change with this TCP change. In order to support high throughput, we have designed a zero-copy solution for the data transmission path in our system. Typically, the MTU in our environment is also 1500 bytes. 1. On one core, the iob_s buffer is set to be used directly by the hardware accelerator. We reserve 32 bytes of space in front of the 1500-length payload buffer for the hardware accelerator to use. To ensure data consistency (between RAM and CPU Cache), the reserved 32-byte space needs to be aligned according to the CPU cache line size. From the perspective of data flow, the iob data sent by the tcpip stack is directly consumed by the HW, and the iob data received from the HW is sent to the TCPIP stack for consumption, and only copied when it needs to be sent to the application. 2. On another core, it may be need to forward some IP frames received from one network driver to the USB RNDIS network driver, which is also a zero-copy implementation. We do not copy the data content during the forwarding process, when the ethernet packet is sent to the USB HW, a 42-byte space aligned with the current CPU cache line size is reserved before the Ethernet frame. As mentioned above, one core needs cache line-aligned iob buffers of 1500+32 bytes, and the other core needs cache line-aligned iob buffers of 1500+42 bytes. Because iob has only one size configuration, other stacks can only use this size of iob buffer. -- 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