* mbuf data is 1400 bytes but the most common (?) use, Ethernet II frames, allow for 1518 bytes @ 2023-10-04 6:52 Nicolson Ken (ニコルソン ケン) 2023-10-04 7:19 ` Dmitry Kozlyuk 0 siblings, 1 reply; 3+ messages in thread From: Nicolson Ken (ニコルソン ケン) @ 2023-10-04 6:52 UTC (permalink / raw) To: users Hi all, Looking at sending Ethernet packets over a DPDK connection, I see that an Ethernet Type II frame has 1518 max, but mbuf's data block is 1400 bytes. Is this what the headroom and tailroom are for? I see example code that uses the headroom for the MAC Header, but what is the preferred way of copying a 1518 Ethernet packet into an mbuf? Should I use rte_pktmbuf_append() to reserve the extra bytes, or is there a better way? Thanks, Ken ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: mbuf data is 1400 bytes but the most common (?) use, Ethernet II frames, allow for 1518 bytes 2023-10-04 6:52 mbuf data is 1400 bytes but the most common (?) use, Ethernet II frames, allow for 1518 bytes Nicolson Ken (ニコルソン ケン) @ 2023-10-04 7:19 ` Dmitry Kozlyuk 2023-10-05 2:28 ` Nicolson Ken (ニコルソン ケン) 0 siblings, 1 reply; 3+ messages in thread From: Dmitry Kozlyuk @ 2023-10-04 7:19 UTC (permalink / raw) To: Nicolson Ken (ニコルソン ケン) Cc: users Hi Ken, 2023-10-04 06:52 (UTC+0000), Nicolson Ken (ニコルソン ケン): > Looking at sending Ethernet packets over a DPDK connection, I see that an > Ethernet Type II frame has 1518 max, but mbuf's data block is 1400 bytes. rte_mbuf has no fixed-length "data block", so there is no limitation of 1400. Buffer size is usually configured when creating a packet mempool. Typically (rte_mbuf_core.h): /** * Some NICs need at least 2KB buffer to RX standard Ethernet frame without * splitting it into multiple segments. * So, for mbufs that planned to be involved into RX/TX, the recommended * minimal buffer length is 2KB + RTE_PKTMBUF_HEADROOM. */ #define RTE_MBUF_DEFAULT_DATAROOM 2048 #define RTE_MBUF_DEFAULT_BUF_SIZE \ (RTE_MBUF_DEFAULT_DATAROOM + RTE_PKTMBUF_HEADROOM) > Is this what the headroom and tailroom are for? It is for prepending headers/trailers without copying the packet into a new buffer, that is, it is used to change the packet efficiently. Sometimes some headers still need to be moved, but not the entire frame. Documentation shows how headroom, dataroom, tailroom, and buffer are related: https://doc.dpdk.org/guides/prog_guide/mbuf_lib.html > I see example code that uses the headroom for the MAC Header, but what is > the preferred way of copying a 1518 Ethernet packet into an mbuf? Should I > use rte_pktmbuf_append() to reserve the extra bytes, or is there a better > way? Is the question still relevant given the explanations above? ^ permalink raw reply [flat|nested] 3+ messages in thread
* RE: mbuf data is 1400 bytes but the most common (?) use, Ethernet II frames, allow for 1518 bytes 2023-10-04 7:19 ` Dmitry Kozlyuk @ 2023-10-05 2:28 ` Nicolson Ken (ニコルソン ケン) 0 siblings, 0 replies; 3+ messages in thread From: Nicolson Ken (ニコルソン ケン) @ 2023-10-05 2:28 UTC (permalink / raw) To: Dmitry Kozlyuk; +Cc: users Hi Dmitry, Thanks for that answer; I'd pulled this diagram from a random page without fully checking the source: https://promisechen.github.io/_images/mbuf_layout1.png https://promisechen.github.io/dpdk/zp/mbuf.html I see now that the 1400 bytes was just an example value for demonstration purposes; the official example source code I've looked so far just used the default mempool on rx_queue_setup. I'm teaching myself DPDK, so I'm occasionally fumbling about in the dark. Cheers, Ken -----Original Message----- From: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com> Sent: Wednesday, October 4, 2023 4:20 PM To: Nicolson Ken (ニコルソン ケン) <ken.nicolson@jp.panasonic.com> Cc: users@dpdk.org Subject: Re: mbuf data is 1400 bytes but the most common (?) use, Ethernet II frames, allow for 1518 bytes Hi Ken, 2023-10-04 06:52 (UTC+0000), Nicolson Ken (ニコルソン ケン): > Looking at sending Ethernet packets over a DPDK connection, I see that > an Ethernet Type II frame has 1518 max, but mbuf's data block is 1400 bytes. rte_mbuf has no fixed-length "data block", so there is no limitation of 1400. Buffer size is usually configured when creating a packet mempool. Typically (rte_mbuf_core.h): /** * Some NICs need at least 2KB buffer to RX standard Ethernet frame without * splitting it into multiple segments. * So, for mbufs that planned to be involved into RX/TX, the recommended * minimal buffer length is 2KB + RTE_PKTMBUF_HEADROOM. */ #define RTE_MBUF_DEFAULT_DATAROOM 2048 #define RTE_MBUF_DEFAULT_BUF_SIZE \ (RTE_MBUF_DEFAULT_DATAROOM + RTE_PKTMBUF_HEADROOM) > Is this what the headroom and tailroom are for? It is for prepending headers/trailers without copying the packet into a new buffer, that is, it is used to change the packet efficiently. Sometimes some headers still need to be moved, but not the entire frame. Documentation shows how headroom, dataroom, tailroom, and buffer are related: https://doc.dpdk.org/guides/prog_guide/mbuf_lib.html > I see example code that uses the headroom for the MAC Header, but what > is the preferred way of copying a 1518 Ethernet packet into an mbuf? > Should I use rte_pktmbuf_append() to reserve the extra bytes, or is > there a better way? Is the question still relevant given the explanations above? ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-10-05 2:28 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-10-04 6:52 mbuf data is 1400 bytes but the most common (?) use, Ethernet II frames, allow for 1518 bytes Nicolson Ken (ニコルソン ケン) 2023-10-04 7:19 ` Dmitry Kozlyuk 2023-10-05 2:28 ` Nicolson Ken (ニコルソン ケン)
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).