Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero-copy esp_netif_transmit when prepending headers (IDFGH-13434) #14340

Open
3 tasks done
redfast00 opened this issue Aug 8, 2024 · 1 comment
Open
3 tasks done
Assignees
Labels
Status: Opened Issue is new

Comments

@redfast00
Copy link
Contributor

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

General issue report

If you want to make a custom network adaptor with ESP-NETIF, you need to implement three functions:

The signature of the transmit function is esp_err_t esp_netif_transmit(esp_netif_t *esp_netif, void *data, size_t len). This function is called by the network stack. The implementation needs to transmit the data frame to the hardware.

A problem I'm currently facing while implementing esp_netif_transmit, is that I need to prepend some headers to the data before transmitting it via DMA. Since I don't control which buffer I'm passed, I can't prepend the headers directly to the data, so I need to allocate a new, bigger buffer, add the headers and copy the data.

Is there a way to control which buffers are passed to esp_netif_transmit? That way I could add some headroom to the buffer.

Alternatively, is there a way to chain buffers before sending them to the 802.11 MAC TX slots? That way, I could have one DMA entry with the headers which points to the next one that has the data.

@espressif-bot espressif-bot added the Status: Opened Issue is new label Aug 8, 2024
@github-actions github-actions bot changed the title Zero-copy esp_netif_transmit when prepending headers Zero-copy esp_netif_transmit when prepending headers (IDFGH-13434) Aug 8, 2024
@david-cermak
Copy link
Collaborator

You can use esp_netif_transmit_wrap() and use the last argument as opaque pointer to your DMA buffer struct.
the default wlan port passes lwip's pbuf as the network stack buffer (these pbufs support prep-ending and chaining, too)

netif_ret = esp_netif_transmit_wrap(esp_netif, q->payload, q->len, q);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new
Projects
None yet
Development

No branches or pull requests

3 participants