mirror of
https://github.com/openvswitch/ovs
synced 2025-09-02 23:35:27 +00:00
netdev-dpdk: Add mbuf HEADROOM after alignment.
Commitdfaf00e
started using the result of dpdk_buf_size() to calculate the available size on each mbuf, as opposed to using the previous MBUF_SIZE macro. However, this was calculating the mbuf size by adding up the MTU with RTE_PKTMBUF_HEADROOM and only then aligning to NETDEV_DPDK_MBUF_ALIGN. Instead, the accounting for the RTE_PKTMBUF_HEADROOM should only happen after alignment, as per below. Before alignment: ROUNDUP(MTU(1500) + RTE_PKTMBUF_HEADROOM(128), 1024) = 2048 After aligment: ROUNDUP(MTU(1500), 1024) + 128 = 2176 This might seem insignificant, however, it might have performance implications in DPDK, where each mbuf is expected to have 2k + RTE_PKTMBUF_HEADROOM of available space. This is because not only some NICs have course grained alignments of 1k, they will also take RTE_PKTMBUF_HEADROOM bytes from the overall available space in an mbuf when setting up their Rx requirements. Thus, only the "After alignment" case above would guarantee a 2k of available room, as the "Before alignment" would report only 1920B. Some extra information can be found at: https://mails.dpdk.org/archives/dev/2018-November/119219.html Note: This has been found by Ian Stokes while going through some af_packet checks. Reported-by: Ian Stokes <ian.stokes@intel.com> Fixes:dfaf00e
("netdev-dpdk: fix mbuf sizing") Signed-off-by: Tiago Lam <tiago.lam@intel.com> Signed-off-by: Ian Stokes <ian.stokes@intel.com>
This commit is contained in:
@@ -521,8 +521,8 @@ is_dpdk_class(const struct netdev_class *class)
|
||||
static uint32_t
|
||||
dpdk_buf_size(int mtu)
|
||||
{
|
||||
return ROUND_UP((MTU_TO_MAX_FRAME_LEN(mtu) + RTE_PKTMBUF_HEADROOM),
|
||||
NETDEV_DPDK_MBUF_ALIGN);
|
||||
return ROUND_UP(MTU_TO_MAX_FRAME_LEN(mtu), NETDEV_DPDK_MBUF_ALIGN)
|
||||
+ RTE_PKTMBUF_HEADROOM;
|
||||
}
|
||||
|
||||
/* Allocates an area of 'sz' bytes from DPDK. The memory is zero'ed.
|
||||
@@ -681,6 +681,8 @@ dpdk_mp_create(struct netdev_dpdk *dev, int mtu, bool per_port_mp)
|
||||
dev->requested_n_rxq, dev->requested_n_txq,
|
||||
RTE_CACHE_LINE_SIZE);
|
||||
|
||||
/* The size of the mbuf's private area (i.e. area that holds OvS'
|
||||
* dp_packet data)*/
|
||||
mbuf_priv_data_len = sizeof(struct dp_packet) -
|
||||
sizeof(struct rte_mbuf);
|
||||
/* The size of the entire dp_packet. */
|
||||
|
Reference in New Issue
Block a user