Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is odd
Hi Helin, Hi Olivier,
we are seeing an issue with the ixgbe and i40e drivers which we could track down to our setting of the private area size of the mbufs. The issue can be easily reproduced with the l2fwd example application when a small modification is done: just set the priv_size parameter in the call to the rte_pktmbuf_pool_create function to an odd number like
1. In our tests this causes every call to rte_eth_rx_burst to return 32 (which is the setting of nb_pkts) nonsense mbufs although no packets are received on the interface and the hardware counters do not report any received packets.
Interestingly this does not happen if we force the scattered rx path.
I assume the drivers have some expectations regarding the alignment of the buf_addr in the mbuf and setting an odd private are size breaks this alignment in the rte_pktmbuf_init function. If this is the case then one possible fix might be to enforce an alignment on the private area size.
Best regards,
Martin
Hi Martin,
Quoted 9 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Martin Weiser
Sent: Wednesday, July 29, 2015 4:07 PM
To: Zhang, Helin; [email protected]
Cc: [email protected]
Subject: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi Helin, Hi Olivier,
Quoted 9 lines
we are seeing an issue with the ixgbe and i40e drivers which we could track down to our setting of the private area size of the mbufs. The issue can be easily reproduced with the l2fwd example application when a small modification is done: just set the
priv_sizeparameter in the call to therte_pktmbuf_pool_createfunction to an odd number like
1. In our tests this causes every call torte_eth_rx_burstto return 32 (which is the setting ofnb_pkts) nonsense mbufs although no packets are received on the interface and the hardware counters do not report any received packets.
From Niantic datasheet:
"7.1.6.1 Advanced Receive Descriptors — Read Format
Table 7-15 lists the advanced receive descriptor programming by the software. The
...
Packet Buffer Address (64)
This is the physical address of the packet buffer. The lowest bit is A0 (LSB of the address).
Header Buffer Address (64)
The physical address of the header buffer with the lowest bit being Descriptor Done (DD). When a packet spans in multiple descriptors, the header buffer address is used only on the first descriptor. During the programming phase, software must set the DD bit to zero (see the description of the DD bit in this section). This means that header buffer addresses are always word aligned."
Right now, in ixgbe PMD we always setup Packet Buffer Address (PBA)and Header Buffer Address (HBA) to the same value:buf_physaddr + RTE_PKTMBUF_HEADROOM
So when pirv_size==1, DD bit in RXD is always set to one by SW itself, and then SW considers that HW already done with it. In other words, right now for ixgbe you can't use RX buffer that is not aligned on word boundary.
So the advice would be, right now - don't set priv_size to the odd value.
As we don't support split header feature anyway, I think we can fix it just by always setting HBA in the RXD to zero. Could you try the fix for ixgbe below?
Same story with FVL, I believe.
Konstantin
Quoted 9 lines
Interestingly this does not happen if we force the scattered rx path.
I assume the drivers have some expectations regarding the alignment of the
buf_addrin the mbuf and setting an odd private are size breaks this alignment in therte_pktmbuf_initfunction. If this is the case then one possible fix might be to enforce an alignment on the private area size.Best regards,
Martin
drivers/net/ixgbe/ixgbe_rxtx.c +4 -4
@@ -1183,7 +1183,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)/* populate the descriptors */ dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb)); - rxdp[i].read.hdr_addr = dma_addr; + rxdp[i].read.hdr_addr =0 ; rxdp[i].read.pkt_addr = dma_addr; }
@@ -1414,7 +1414,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxe->mbuf = nmb; dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (nmb)); - rxdp->read.hdr_addr = dma_addr; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma_addr;/*
@@ -1741,7 +1741,7 @@ next_desc: rxe->mbuf = nmb; rxm->data_off =RTE_PKTMBUF_HEADROOM ; - rxdp->read.hdr_addr = dma; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma; }else rxe->mbuf =NULL ;
@@ -3633,7 +3633,7 @@ ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq) dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mbuf)); rxd = &rxq->rx_ring[i]; - rxd->read.hdr_addr = dma_addr; + rxd->read.hdr_addr =0 ; rxd->read.pkt_addr = dma_addr; rxe[i].mbuf = mbuf; }
drivers/net/ixgbe/ixgbe_rxtx_vec.c +5 -0
@@ -56,6 +56,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) RTE_PKTMBUF_HEADROOM);__m128i dma_addr0, dma_addr1; +const __m128i hba_msk =_mm_set_epi64x (0 ,UINT64_MAX ); + rxdp = rxq->rx_ring + rxq->rxrearm_start;/* Pull 'n' more MBUFs into the software ring */
@@ -108,6 +110,9 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) dma_addr0 =_mm_add_epi64 (dma_addr0, hdr_room); dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room); + dma_addr0 =_mm_and_si128 (dma_addr0, hba_msk); + dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk); +/* flush desc with pa dma_addr */ _mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0);_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1);
bash-4.2$ cat patch1
drivers/net/ixgbe/ixgbe_rxtx.c +4 -4
@@ -1183,7 +1183,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)/* populate the descriptors */ dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb)); - rxdp[i].read.hdr_addr = dma_addr; + rxdp[i].read.hdr_addr =0 ; rxdp[i].read.pkt_addr = dma_addr; }
@@ -1414,7 +1414,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxe->mbuf = nmb; dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (nmb)); - rxdp->read.hdr_addr = dma_addr; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma_addr;/*
@@ -1741,7 +1741,7 @@ next_desc: rxe->mbuf = nmb; rxm->data_off =RTE_PKTMBUF_HEADROOM ; - rxdp->read.hdr_addr = dma; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma; }else rxe->mbuf =NULL ;
@@ -3633,7 +3633,7 @@ ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq) dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mbuf)); rxd = &rxq->rx_ring[i]; - rxd->read.hdr_addr = dma_addr; + rxd->read.hdr_addr =0 ; rxd->read.pkt_addr = dma_addr; rxe[i].mbuf = mbuf; }
drivers/net/ixgbe/ixgbe_rxtx_vec.c +5 -0
@@ -56,6 +56,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) RTE_PKTMBUF_HEADROOM);__m128i dma_addr0, dma_addr1; +const __m128i hba_msk =_mm_set_epi64x (0 ,UINT64_MAX ); + rxdp = rxq->rx_ring + rxq->rxrearm_start;/* Pull 'n' more MBUFs into the software ring */
@@ -108,6 +110,9 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) dma_addr0 =_mm_add_epi64 (dma_addr0, hdr_room); dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room); + dma_addr0 =_mm_and_si128 (dma_addr0, hba_msk); + dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk); +/* flush desc with pa dma_addr */ _mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0);_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1);
Hi Martin
Thank you very much for the good catch!
The similar situation in i40e, as explained by Konstantin.
As header split hasn't been supported by DPDK till now. It would be better to put the header address in RX descriptor to 0.
But in the future, during header split enabling. We may need to pay extra attention to that. As at least x710 datasheet said specifically as below. "The header address should be set by the software to an even number (word aligned address)". We may need to find a way to ensure that during mempool/mbuf allocation.
Regards,
Helin
Quoted 210 lines
-----Original Message-----
From: Ananyev, Konstantin
Sent: Wednesday, July 29, 2015 11:12 AM
To: Martin Weiser; Zhang, Helin; [email protected]
Cc: [email protected]
Subject: RE: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi Martin,
Quoted 10 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Martin Weiser
Sent: Wednesday, July 29, 2015 4:07 PM
To: Zhang, Helin; [email protected]
Cc: [email protected]
Subject: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi Helin, Hi Olivier,
Quoted 9 lines
we are seeing an issue with the ixgbe and i40e drivers which we could track down to our setting of the private area size of the mbufs. The issue can be easily reproduced with the l2fwd example application when a small modification is done: just set the
priv_sizeparameter in the call to therte_pktmbuf_pool_createfunction to an odd number like
1. In our tests this causes every call torte_eth_rx_burstto return 32 (which is the setting ofnb_pkts) nonsense mbufs although no packets are received on the interface and the hardware counters do not report any received packets.From Niantic datasheet:
"7.1.6.1 Advanced Receive Descriptors — Read Format Table 7-15 lists the advanced receive descriptor programming by the software. The ... Packet Buffer Address (64)
This is the physical address of the packet buffer. The lowest bit is A0 (LSB of the address).
Header Buffer Address (64)
The physical address of the header buffer with the lowest bit being Descriptor Done (DD).
When a packet spans in multiple descriptors, the header buffer address is used only on the first descriptor. During the programming phase, software must set the DD bit to zero (see the description of the DD bit in this section). This means that header buffer addresses are always word aligned."Right now, in ixgbe PMD we always setup Packet Buffer Address (PBA)and Header Buffer Address (HBA) to the same value:
buf_physaddr+RTE_PKTMBUF_HEADROOM
So when pirv_size==1, DD bit in RXD is always set to one by SW itself, and then SW considers that HW already done with it.
In other words, right now for ixgbe you can't use RX buffer that is not aligned on word boundary.So the advice would be, right now - don't set
priv_sizeto the odd value. As we don't support split header feature anyway, I think we can fix it just by always setting HBA in the RXD to zero.
Could you try the fix for ixgbe below?Same story with FVL, I believe.
KonstantinQuoted 9 lines
Interestingly this does not happen if we force the scattered rx path.
I assume the drivers have some expectations regarding the alignment of the
buf_addrin the mbuf and setting an odd private are size breaks this alignment in therte_pktmbuf_initfunction. If this is the case then one possible fix might be to enforce an alignment on the private area size.Best regards,
Martindrivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1183,7 +1183,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)/* populate the descriptors */ dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb)); - rxdp[i].read.hdr_addr = dma_addr; + rxdp[i].read.hdr_addr =0 ; rxdp[i].read.pkt_addr = dma_addr;}drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1414,7 +1414,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxe->mbuf = nmb; dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (nmb)); - rxdp->read.hdr_addr = dma_addr; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma_addr;/*drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1741,7 +1741,7 @@ next_desc: rxe->mbuf = nmb; rxm->data_off =RTE_PKTMBUF_HEADROOM ; - rxdp->read.hdr_addr = dma; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma; }else rxe->mbuf = NULL; @@ -3633,7 +3633,7 @@
ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq)
dma_addr=rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mbuf)); rxd = &rxq->rx_ring[i];drivers/net/ixgbe/ixgbe_rxtx.c +1
-1- rxd->read.hdr_addr = dma_addr; + rxd->read.hdr_addr =0 ; rxd->read.pkt_addr = dma_addr; rxe[i].mbuf = mbuf; }drivers/net/ixgbe/ixgbe_rxtx_vec.c +2
-0@@ -56,6 +56,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) RTE_PKTMBUF_HEADROOM);__m128i dma_addr0, dma_addr1; +const __m128i hba_msk =_mm_set_epi64x (0 ,UINT64_MAX ); + rxdp = rxq->rx_ring + rxq->rxrearm_start; /* Pull 'n' more MBUFs into the software ring */ @@ -108,6 +110,9 @@
ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)dma_addr0 = _mm_add_epi64(dma_addr0, hdr_room); dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);drivers/net/ixgbe/ixgbe_rxtx_vec.c +3
-0+ dma_addr0 =_mm_and_si128 (dma_addr0, hba_msk); + dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk); +/* flush desc with pa dma_addr */ _mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0);_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1);bash-4.2$ cat patch1 diff --git
a/drivers/net/ixgbe/ixgbe_rxtx.cb/drivers/net/ixgbe/ixgbe_rxtx.cindex a0c8847..94967c5 100644drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1183,7 +1183,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)/* populate the descriptors */ dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb)); - rxdp[i].read.hdr_addr = dma_addr; + rxdp[i].read.hdr_addr =0 ; rxdp[i].read.pkt_addr = dma_addr;}drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1414,7 +1414,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxe->mbuf = nmb; dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (nmb)); - rxdp->read.hdr_addr = dma_addr; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma_addr;/*drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1741,7 +1741,7 @@ next_desc: rxe->mbuf = nmb; rxm->data_off =RTE_PKTMBUF_HEADROOM ; - rxdp->read.hdr_addr = dma; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma; }else rxe->mbuf = NULL; @@ -3633,7 +3633,7 @@
ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq)
dma_addr=rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mbuf)); rxd = &rxq->rx_ring[i];drivers/net/ixgbe/ixgbe_rxtx.c +1
-1- rxd->read.hdr_addr = dma_addr; + rxd->read.hdr_addr =0 ; rxd->read.pkt_addr = dma_addr; rxe[i].mbuf = mbuf; }drivers/net/ixgbe/ixgbe_rxtx_vec.c +2
-0@@ -56,6 +56,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) RTE_PKTMBUF_HEADROOM);__m128i dma_addr0, dma_addr1; +const __m128i hba_msk =_mm_set_epi64x (0 ,UINT64_MAX ); + rxdp = rxq->rx_ring + rxq->rxrearm_start; /* Pull 'n' more MBUFs into the software ring */ @@ -108,6 +110,9 @@
ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)dma_addr0 = _mm_add_epi64(dma_addr0, hdr_room); dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);drivers/net/ixgbe/ixgbe_rxtx_vec.c +3
-0+ dma_addr0 =_mm_and_si128 (dma_addr0, hba_msk); + dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk); +/* flush desc with pa dma_addr */ _mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0);_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1);
Hi,
Quoted 8 lines · Helin
Hi Martin
Thank you very much for the good catch!
The similar situation in i40e, as explained by Konstantin.
As header split hasn't been supported by DPDK till now. It would be better to put the header address in RX descriptor to 0.
But in the future, during header split enabling. We may need to pay extra attention to that. As at least x710 datasheet said specifically as below. "The header address should be set by the software to an even number (word aligned address)". We may need to find a way to ensure that during mempool/mbuf allocation.
Indeed it would be good to force the priv_size to be aligned.
The priv_size could be aligned automatically in rte_pktmbuf_pool_create(). The only possible problem I could see is that it would break applications that access to the data buffer by doing (sizeof(mbuf) + sizeof(priv)), which is probably not the best thing to do (I didn't find any applications like this in dpdk).
For applications that directly use rte_mempool_create() instead ofrte_pktmbuf_pool_create(), we could add a check using an assert in rte_pktmbuf_init() and some words in the documentation.
The question is: what should be the proper alignment? I would say at least 8 bytes, but maybe cache_aligned is an option too.
Regards,
Olivier
Quoted 214 lines
Regards,
HelinQuoted 210 lines
-----Original Message-----
From: Ananyev, Konstantin
Sent: Wednesday, July 29, 2015 11:12 AM
To: Martin Weiser; Zhang, Helin; [email protected]
Cc: [email protected]
Subject: RE: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi Martin,
Quoted 10 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Martin Weiser
Sent: Wednesday, July 29, 2015 4:07 PM
To: Zhang, Helin; [email protected]
Cc: [email protected]
Subject: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi Helin, Hi Olivier,
Quoted 9 lines
we are seeing an issue with the ixgbe and i40e drivers which we could track down to our setting of the private area size of the mbufs. The issue can be easily reproduced with the l2fwd example application when a small modification is done: just set the
priv_sizeparameter in the call to therte_pktmbuf_pool_createfunction to an odd number like
1. In our tests this causes every call torte_eth_rx_burstto return 32 (which is the setting ofnb_pkts) nonsense mbufs although no packets are received on the interface and the hardware counters do not report any received packets.From Niantic datasheet:
"7.1.6.1 Advanced Receive Descriptors — Read Format Table 7-15 lists the advanced receive descriptor programming by the software. The ... Packet Buffer Address (64)
This is the physical address of the packet buffer. The lowest bit is A0 (LSB of the address).
Header Buffer Address (64)
The physical address of the header buffer with the lowest bit being Descriptor Done (DD).
When a packet spans in multiple descriptors, the header buffer address is used only on the first descriptor. During the programming phase, software must set the DD bit to zero (see the description of the DD bit in this section). This means that header buffer addresses are always word aligned."Right now, in ixgbe PMD we always setup Packet Buffer Address (PBA)and Header Buffer Address (HBA) to the same value:
buf_physaddr+RTE_PKTMBUF_HEADROOM
So when pirv_size==1, DD bit in RXD is always set to one by SW itself, and then SW considers that HW already done with it.
In other words, right now for ixgbe you can't use RX buffer that is not aligned on word boundary.So the advice would be, right now - don't set
priv_sizeto the odd value. As we don't support split header feature anyway, I think we can fix it just by always setting HBA in the RXD to zero.
Could you try the fix for ixgbe below?Same story with FVL, I believe.
KonstantinQuoted 9 lines
Interestingly this does not happen if we force the scattered rx path.
I assume the drivers have some expectations regarding the alignment of the
buf_addrin the mbuf and setting an odd private are size breaks this alignment in therte_pktmbuf_initfunction. If this is the case then one possible fix might be to enforce an alignment on the private area size.Best regards,
Martindrivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1183,7 +1183,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)/* populate the descriptors */ dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb)); - rxdp[i].read.hdr_addr = dma_addr; + rxdp[i].read.hdr_addr =0 ; rxdp[i].read.pkt_addr = dma_addr;}drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1414,7 +1414,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxe->mbuf = nmb; dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (nmb)); - rxdp->read.hdr_addr = dma_addr; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma_addr;/*drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1741,7 +1741,7 @@ next_desc: rxe->mbuf = nmb; rxm->data_off =RTE_PKTMBUF_HEADROOM ; - rxdp->read.hdr_addr = dma; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma; }else rxe->mbuf = NULL; @@ -3633,7 +3633,7 @@
ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq)
dma_addr=rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mbuf)); rxd = &rxq->rx_ring[i];drivers/net/ixgbe/ixgbe_rxtx.c +1
-1- rxd->read.hdr_addr = dma_addr; + rxd->read.hdr_addr =0 ; rxd->read.pkt_addr = dma_addr; rxe[i].mbuf = mbuf; }drivers/net/ixgbe/ixgbe_rxtx_vec.c +2
-0@@ -56,6 +56,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) RTE_PKTMBUF_HEADROOM);__m128i dma_addr0, dma_addr1; +const __m128i hba_msk =_mm_set_epi64x (0 ,UINT64_MAX ); + rxdp = rxq->rx_ring + rxq->rxrearm_start; /* Pull 'n' more MBUFs into the software ring */ @@ -108,6 +110,9 @@
ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)dma_addr0 = _mm_add_epi64(dma_addr0, hdr_room); dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);drivers/net/ixgbe/ixgbe_rxtx_vec.c +3
-0+ dma_addr0 =_mm_and_si128 (dma_addr0, hba_msk); + dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk); +/* flush desc with pa dma_addr */ _mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0);_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1);bash-4.2$ cat patch1 diff --git
a/drivers/net/ixgbe/ixgbe_rxtx.cb/drivers/net/ixgbe/ixgbe_rxtx.cindex a0c8847..94967c5 100644drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1183,7 +1183,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)/* populate the descriptors */ dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb)); - rxdp[i].read.hdr_addr = dma_addr; + rxdp[i].read.hdr_addr =0 ; rxdp[i].read.pkt_addr = dma_addr;}drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1414,7 +1414,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxe->mbuf = nmb; dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (nmb)); - rxdp->read.hdr_addr = dma_addr; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma_addr;/*drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1741,7 +1741,7 @@ next_desc: rxe->mbuf = nmb; rxm->data_off =RTE_PKTMBUF_HEADROOM ; - rxdp->read.hdr_addr = dma; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma; }else rxe->mbuf = NULL; @@ -3633,7 +3633,7 @@
ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq)
dma_addr=rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mbuf)); rxd = &rxq->rx_ring[i];drivers/net/ixgbe/ixgbe_rxtx.c +1
-1- rxd->read.hdr_addr = dma_addr; + rxd->read.hdr_addr =0 ; rxd->read.pkt_addr = dma_addr; rxe[i].mbuf = mbuf; }drivers/net/ixgbe/ixgbe_rxtx_vec.c +2
-0@@ -56,6 +56,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) RTE_PKTMBUF_HEADROOM);__m128i dma_addr0, dma_addr1; +const __m128i hba_msk =_mm_set_epi64x (0 ,UINT64_MAX ); + rxdp = rxq->rx_ring + rxq->rxrearm_start; /* Pull 'n' more MBUFs into the software ring */ @@ -108,6 +110,9 @@
ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)dma_addr0 = _mm_add_epi64(dma_addr0, hdr_room); dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);drivers/net/ixgbe/ixgbe_rxtx_vec.c +3
-0+ dma_addr0 =_mm_and_si128 (dma_addr0, hba_msk); + dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk); +/* flush desc with pa dma_addr */ _mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0);_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1);
Hi Olivier,
Quoted 21 lines
-----Original Message-----
From: Olivier MATZ [mailto:[email protected]]
Sent: Thursday, July 30, 2015 9:12 AM
To: Zhang, Helin; Ananyev, Konstantin; Martin Weiser
Cc: [email protected]
Subject: Re: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi,
Quoted 7 lines · Helin
Hi Martin
Thank you very much for the good catch!
The similar situation in i40e, as explained by Konstantin.
As header split hasn't been supported by DPDK till now. It would be better to put the header address in RX descriptor to 0. But in the future, during header split enabling. We may need to pay extra attention to that. As at least x710 datasheet saidspecifically as below.
Quoted 1 line
"The header address should be set by the software to an even number (word aligned address)". We may need to find a way to
ensure that during mempool/mbuf allocation.
Quoted 7 lines
Indeed it would be good to force the
priv_sizeto be aligned.The
priv_sizecould be aligned automatically inrte_pktmbuf_pool_create(). The only possible problem I could see is that it would break applications that access to the data buffer by doing (sizeof(mbuf) + sizeof(priv)), which is probably not the best thing to do (I didn't find any applications like this in dpdk).
Might be just make rte_pktmbuf_pool_create() fail if input priv_size % MIN_ALIGN != 0?
Quoted 7 lines
For applications that directly use
rte_mempool_create()instead ofrte_pktmbuf_pool_create(), we could add a check using an assert inrte_pktmbuf_init()and some words in the documentation.The question is: what should be the proper alignment? I would say at least 8 bytes, but maybe
cache_alignedis an option too.
8 bytes seems enough to me.
Konstantin
Quoted 219 lines
Regards,
OlivierQuoted 214 lines
Regards,
HelinQuoted 210 lines
-----Original Message-----
From: Ananyev, Konstantin
Sent: Wednesday, July 29, 2015 11:12 AM
To: Martin Weiser; Zhang, Helin; [email protected]
Cc: [email protected]
Subject: RE: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi Martin,
Quoted 10 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Martin Weiser
Sent: Wednesday, July 29, 2015 4:07 PM
To: Zhang, Helin; [email protected]
Cc: [email protected]
Subject: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi Helin, Hi Olivier,
Quoted 9 lines
we are seeing an issue with the ixgbe and i40e drivers which we could track down to our setting of the private area size of the mbufs. The issue can be easily reproduced with the l2fwd example application when a small modification is done: just set the
priv_sizeparameter in the call to therte_pktmbuf_pool_createfunction to an odd number like
1. In our tests this causes every call torte_eth_rx_burstto return 32 (which is the setting ofnb_pkts) nonsense mbufs although no packets are received on the interface and the hardware counters do not report any received packets.From Niantic datasheet:
"7.1.6.1 Advanced Receive Descriptors — Read Format Table 7-15 lists the advanced receive descriptor programming by the software. The ... Packet Buffer Address (64)
This is the physical address of the packet buffer. The lowest bit is A0 (LSB of the address).
Header Buffer Address (64)
The physical address of the header buffer with the lowest bit being Descriptor Done (DD).
When a packet spans in multiple descriptors, the header buffer address is used only on the first descriptor. During the programming phase, software must set the DD bit to zero (see the description of the DD bit in this section). This means that header buffer addresses are always word aligned."Right now, in ixgbe PMD we always setup Packet Buffer Address (PBA)and Header Buffer Address (HBA) to the same value:
buf_physaddr+RTE_PKTMBUF_HEADROOM
So when pirv_size==1, DD bit in RXD is always set to one by SW itself, and then SW considers that HW already done with it.
In other words, right now for ixgbe you can't use RX buffer that is not aligned on word boundary.So the advice would be, right now - don't set
priv_sizeto the odd value. As we don't support split header feature anyway, I think we can fix it just by always setting HBA in the RXD to zero.
Could you try the fix for ixgbe below?Same story with FVL, I believe.
KonstantinQuoted 9 lines
Interestingly this does not happen if we force the scattered rx path.
I assume the drivers have some expectations regarding the alignment of the
buf_addrin the mbuf and setting an odd private are size breaks this alignment in therte_pktmbuf_initfunction. If this is the case then one possible fix might be to enforce an alignment on the private area size.Best regards,
Martindrivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1183,7 +1183,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)/* populate the descriptors */ dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb)); - rxdp[i].read.hdr_addr = dma_addr; + rxdp[i].read.hdr_addr =0 ; rxdp[i].read.pkt_addr = dma_addr;}drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1414,7 +1414,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxe->mbuf = nmb; dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (nmb)); - rxdp->read.hdr_addr = dma_addr; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma_addr;/*drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1741,7 +1741,7 @@ next_desc: rxe->mbuf = nmb; rxm->data_off =RTE_PKTMBUF_HEADROOM ; - rxdp->read.hdr_addr = dma; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma; }else rxe->mbuf = NULL; @@ -3633,7 +3633,7 @@
ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq)
dma_addr=rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mbuf)); rxd = &rxq->rx_ring[i];drivers/net/ixgbe/ixgbe_rxtx.c +1
-1- rxd->read.hdr_addr = dma_addr; + rxd->read.hdr_addr =0 ; rxd->read.pkt_addr = dma_addr; rxe[i].mbuf = mbuf; }drivers/net/ixgbe/ixgbe_rxtx_vec.c +2
-0@@ -56,6 +56,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) RTE_PKTMBUF_HEADROOM);__m128i dma_addr0, dma_addr1; +const __m128i hba_msk =_mm_set_epi64x (0 ,UINT64_MAX ); + rxdp = rxq->rx_ring + rxq->rxrearm_start; /* Pull 'n' more MBUFs into the software ring */ @@ -108,6 +110,9 @@
ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)dma_addr0 = _mm_add_epi64(dma_addr0, hdr_room); dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);drivers/net/ixgbe/ixgbe_rxtx_vec.c +3
-0+ dma_addr0 =_mm_and_si128 (dma_addr0, hba_msk); + dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk); +/* flush desc with pa dma_addr */ _mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0);_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1);bash-4.2$ cat patch1 diff --git
a/drivers/net/ixgbe/ixgbe_rxtx.cb/drivers/net/ixgbe/ixgbe_rxtx.cindex a0c8847..94967c5 100644drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1183,7 +1183,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)/* populate the descriptors */ dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb)); - rxdp[i].read.hdr_addr = dma_addr; + rxdp[i].read.hdr_addr =0 ; rxdp[i].read.pkt_addr = dma_addr;}drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1414,7 +1414,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxe->mbuf = nmb; dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (nmb)); - rxdp->read.hdr_addr = dma_addr; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma_addr;/*drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1741,7 +1741,7 @@ next_desc: rxe->mbuf = nmb; rxm->data_off =RTE_PKTMBUF_HEADROOM ; - rxdp->read.hdr_addr = dma; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma; }else rxe->mbuf = NULL; @@ -3633,7 +3633,7 @@
ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq)
dma_addr=rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mbuf)); rxd = &rxq->rx_ring[i];drivers/net/ixgbe/ixgbe_rxtx.c +1
-1- rxd->read.hdr_addr = dma_addr; + rxd->read.hdr_addr =0 ; rxd->read.pkt_addr = dma_addr; rxe[i].mbuf = mbuf; }drivers/net/ixgbe/ixgbe_rxtx_vec.c +2
-0@@ -56,6 +56,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) RTE_PKTMBUF_HEADROOM);__m128i dma_addr0, dma_addr1; +const __m128i hba_msk =_mm_set_epi64x (0 ,UINT64_MAX ); + rxdp = rxq->rx_ring + rxq->rxrearm_start; /* Pull 'n' more MBUFs into the software ring */ @@ -108,6 +110,9 @@
ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)dma_addr0 = _mm_add_epi64(dma_addr0, hdr_room); dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);drivers/net/ixgbe/ixgbe_rxtx_vec.c +3
-0+ dma_addr0 =_mm_and_si128 (dma_addr0, hba_msk); + dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk); +/* flush desc with pa dma_addr */ _mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0);_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1);
Hi Konstantin,
Quoted 25 lines · Konstantin
Hi Olivier,
Quoted 23 lines
-----Original Message-----
From: Olivier MATZ [mailto:[email protected]]
Sent: Thursday, July 30, 2015 9:12 AM
To: Zhang, Helin; Ananyev, Konstantin; Martin Weiser
Cc: [email protected]
Subject: Re: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi,
Quoted 7 lines · Helin
Hi Martin
Thank you very much for the good catch!
The similar situation in i40e, as explained by Konstantin.
As header split hasn't been supported by DPDK till now. It would be better to put the header address in RX descriptor to 0. But in the future, during header split enabling. We may need to pay extra attention to that. As at least x710 datasheet saidspecifically as below.
Quoted 1 line
"The header address should be set by the software to an even number (word aligned address)". We may need to find a way to
ensure that during mempool/mbuf allocation.
Indeed it would be good to force the
priv_sizeto be aligned.
Quoted 8 lines
Quoted 5 lines
The
priv_sizecould be aligned automatically inrte_pktmbuf_pool_create(). The only possible problem I could see is that it would break applications that access to the data buffer by doing (sizeof(mbuf) + sizeof(priv)), which is probably not the best thing to do (I didn't find any applications like this in dpdk).Might be just make
rte_pktmbuf_pool_create()fail if inputpriv_size%MIN_ALIGN!= 0?
Hmm maybe it would break more applications: an odd priv_size is probably rare, but a priv_size that is not aligned to 8 bytes is maybe more common.
It's maybe safer to align the size transparently?
Regards,
Olivier
Quoted 233 lines
Quoted 8 lines
For applications that directly use
rte_mempool_create()instead ofrte_pktmbuf_pool_create(), we could add a check using an assert inrte_pktmbuf_init()and some words in the documentation.The question is: what should be the proper alignment? I would say at least 8 bytes, but maybe
cache_alignedis an option too.8 bytes seems enough to me.
Konstantin
Quoted 219 lines
Regards,
OlivierQuoted 214 lines
Regards,
HelinQuoted 210 lines
-----Original Message-----
From: Ananyev, Konstantin
Sent: Wednesday, July 29, 2015 11:12 AM
To: Martin Weiser; Zhang, Helin; [email protected]
Cc: [email protected]
Subject: RE: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi Martin,
Quoted 10 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Martin Weiser
Sent: Wednesday, July 29, 2015 4:07 PM
To: Zhang, Helin; [email protected]
Cc: [email protected]
Subject: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi Helin, Hi Olivier,
Quoted 9 lines
we are seeing an issue with the ixgbe and i40e drivers which we could track down to our setting of the private area size of the mbufs. The issue can be easily reproduced with the l2fwd example application when a small modification is done: just set the
priv_sizeparameter in the call to therte_pktmbuf_pool_createfunction to an odd number like
1. In our tests this causes every call torte_eth_rx_burstto return 32 (which is the setting ofnb_pkts) nonsense mbufs although no packets are received on the interface and the hardware counters do not report any received packets.From Niantic datasheet:
"7.1.6.1 Advanced Receive Descriptors — Read Format Table 7-15 lists the advanced receive descriptor programming by the software. The ... Packet Buffer Address (64)
This is the physical address of the packet buffer. The lowest bit is A0 (LSB of the address).
Header Buffer Address (64)
The physical address of the header buffer with the lowest bit being Descriptor Done (DD).
When a packet spans in multiple descriptors, the header buffer address is used only on the first descriptor. During the programming phase, software must set the DD bit to zero (see the description of the DD bit in this section). This means that header buffer addresses are always word aligned."Right now, in ixgbe PMD we always setup Packet Buffer Address (PBA)and Header Buffer Address (HBA) to the same value:
buf_physaddr+RTE_PKTMBUF_HEADROOM
So when pirv_size==1, DD bit in RXD is always set to one by SW itself, and then SW considers that HW already done with it.
In other words, right now for ixgbe you can't use RX buffer that is not aligned on word boundary.So the advice would be, right now - don't set
priv_sizeto the odd value. As we don't support split header feature anyway, I think we can fix it just by always setting HBA in the RXD to zero.
Could you try the fix for ixgbe below?Same story with FVL, I believe.
KonstantinQuoted 9 lines
Interestingly this does not happen if we force the scattered rx path.
I assume the drivers have some expectations regarding the alignment of the
buf_addrin the mbuf and setting an odd private are size breaks this alignment in therte_pktmbuf_initfunction. If this is the case then one possible fix might be to enforce an alignment on the private area size.Best regards,
Martindrivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1183,7 +1183,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)/* populate the descriptors */ dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb)); - rxdp[i].read.hdr_addr = dma_addr; + rxdp[i].read.hdr_addr =0 ; rxdp[i].read.pkt_addr = dma_addr;}drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1414,7 +1414,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxe->mbuf = nmb; dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (nmb)); - rxdp->read.hdr_addr = dma_addr; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma_addr;/*drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1741,7 +1741,7 @@ next_desc: rxe->mbuf = nmb; rxm->data_off =RTE_PKTMBUF_HEADROOM ; - rxdp->read.hdr_addr = dma; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma; }else rxe->mbuf = NULL; @@ -3633,7 +3633,7 @@
ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq)
dma_addr=rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mbuf)); rxd = &rxq->rx_ring[i];drivers/net/ixgbe/ixgbe_rxtx.c +1
-1- rxd->read.hdr_addr = dma_addr; + rxd->read.hdr_addr =0 ; rxd->read.pkt_addr = dma_addr; rxe[i].mbuf = mbuf; }drivers/net/ixgbe/ixgbe_rxtx_vec.c +2
-0@@ -56,6 +56,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) RTE_PKTMBUF_HEADROOM);__m128i dma_addr0, dma_addr1; +const __m128i hba_msk =_mm_set_epi64x (0 ,UINT64_MAX ); + rxdp = rxq->rx_ring + rxq->rxrearm_start; /* Pull 'n' more MBUFs into the software ring */ @@ -108,6 +110,9 @@
ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)dma_addr0 = _mm_add_epi64(dma_addr0, hdr_room); dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);drivers/net/ixgbe/ixgbe_rxtx_vec.c +3
-0+ dma_addr0 =_mm_and_si128 (dma_addr0, hba_msk); + dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk); +/* flush desc with pa dma_addr */ _mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0);_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1);bash-4.2$ cat patch1 diff --git
a/drivers/net/ixgbe/ixgbe_rxtx.cb/drivers/net/ixgbe/ixgbe_rxtx.cindex a0c8847..94967c5 100644drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1183,7 +1183,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)/* populate the descriptors */ dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb)); - rxdp[i].read.hdr_addr = dma_addr; + rxdp[i].read.hdr_addr =0 ; rxdp[i].read.pkt_addr = dma_addr;}drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1414,7 +1414,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxe->mbuf = nmb; dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (nmb)); - rxdp->read.hdr_addr = dma_addr; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma_addr;/*drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1741,7 +1741,7 @@ next_desc: rxe->mbuf = nmb; rxm->data_off =RTE_PKTMBUF_HEADROOM ; - rxdp->read.hdr_addr = dma; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma; }else rxe->mbuf = NULL; @@ -3633,7 +3633,7 @@
ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq)
dma_addr=rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mbuf)); rxd = &rxq->rx_ring[i];drivers/net/ixgbe/ixgbe_rxtx.c +1
-1- rxd->read.hdr_addr = dma_addr; + rxd->read.hdr_addr =0 ; rxd->read.pkt_addr = dma_addr; rxe[i].mbuf = mbuf; }drivers/net/ixgbe/ixgbe_rxtx_vec.c +2
-0@@ -56,6 +56,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) RTE_PKTMBUF_HEADROOM);__m128i dma_addr0, dma_addr1; +const __m128i hba_msk =_mm_set_epi64x (0 ,UINT64_MAX ); + rxdp = rxq->rx_ring + rxq->rxrearm_start; /* Pull 'n' more MBUFs into the software ring */ @@ -108,6 +110,9 @@
ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)dma_addr0 = _mm_add_epi64(dma_addr0, hdr_room); dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);drivers/net/ixgbe/ixgbe_rxtx_vec.c +3
-0+ dma_addr0 =_mm_and_si128 (dma_addr0, hba_msk); + dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk); +/* flush desc with pa dma_addr */ _mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0);_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1);
Quoted 44 lines
-----Original Message-----
From: Olivier MATZ [mailto:[email protected]]
Sent: Thursday, July 30, 2015 10:10 AM
To: Ananyev, Konstantin; Zhang, Helin; Martin Weiser
Cc: [email protected]
Subject: Re: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi Konstantin,
Quoted 32 lines · Konstantin
Hi Olivier,
Quoted 28 lines
-----Original Message-----
From: Olivier MATZ [mailto:[email protected]]
Sent: Thursday, July 30, 2015 9:12 AM
To: Zhang, Helin; Ananyev, Konstantin; Martin Weiser
Cc: [email protected]
Subject: Re: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi,
Quoted 7 lines · Helin
Hi Martin
Thank you very much for the good catch!
The similar situation in i40e, as explained by Konstantin.
As header split hasn't been supported by DPDK till now. It would be better to put the header address in RX descriptor to 0. But in the future, during header split enabling. We may need to pay extra attention to that. As at least x710 datasheet saidspecifically as below.
Quoted 1 line
"The header address should be set by the software to an even number (word aligned address)". We may need to find a way to
ensure that during mempool/mbuf allocation.
Indeed it would be good to force the
priv_sizeto be aligned.The
priv_sizecould be aligned automatically inrte_pktmbuf_pool_create(). The only possible problem I could see is that it would break applications that access to the data buffer by doing (sizeof(mbuf) + sizeof(priv)), which is probably not the best thing to do (I didn't find any applications like this in dpdk).
Quoted 5 lines
Quoted 1 line
Might be just make
rte_pktmbuf_pool_create()fail if inputpriv_size%MIN_ALIGN!= 0?Hmm maybe it would break more applications: an odd
priv_sizeis probably rare, but apriv_sizethat is not aligned to 8 bytes is maybe more common.
My thought was that rte_mempool_create() was just introduced in 2.1, so if we add extra requirement for the input parameter now -
there would be no ABI breakage, and not many people started to use it already. For me just seems a bit easier and more straightforward then silent alignment - user would not have wrong assumptions here.
Though if you think that a silent alignment would be more convenient for most users - I wouldn't insist.
Konstantin
Quoted 241 lines
It's maybe safer to align the size transparently?
Regards,
OlivierQuoted 233 lines
Quoted 8 lines
For applications that directly use
rte_mempool_create()instead ofrte_pktmbuf_pool_create(), we could add a check using an assert inrte_pktmbuf_init()and some words in the documentation.The question is: what should be the proper alignment? I would say at least 8 bytes, but maybe
cache_alignedis an option too.8 bytes seems enough to me.
Konstantin
Quoted 219 lines
Regards,
OlivierQuoted 214 lines
Regards,
HelinQuoted 210 lines
-----Original Message-----
From: Ananyev, Konstantin
Sent: Wednesday, July 29, 2015 11:12 AM
To: Martin Weiser; Zhang, Helin; [email protected]
Cc: [email protected]
Subject: RE: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi Martin,
Quoted 10 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Martin Weiser
Sent: Wednesday, July 29, 2015 4:07 PM
To: Zhang, Helin; [email protected]
Cc: [email protected]
Subject: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi Helin, Hi Olivier,
Quoted 9 lines
we are seeing an issue with the ixgbe and i40e drivers which we could track down to our setting of the private area size of the mbufs. The issue can be easily reproduced with the l2fwd example application when a small modification is done: just set the
priv_sizeparameter in the call to therte_pktmbuf_pool_createfunction to an odd number like
1. In our tests this causes every call torte_eth_rx_burstto return 32 (which is the setting ofnb_pkts) nonsense mbufs although no packets are received on the interface and the hardware counters do not report any received packets.From Niantic datasheet:
"7.1.6.1 Advanced Receive Descriptors — Read Format Table 7-15 lists the advanced receive descriptor programming by the software. The ... Packet Buffer Address (64)
This is the physical address of the packet buffer. The lowest bit is A0 (LSB of the address).
Header Buffer Address (64)
The physical address of the header buffer with the lowest bit being Descriptor Done (DD).
When a packet spans in multiple descriptors, the header buffer address is used only on the first descriptor. During the programming phase, software must set the DD bit to zero (see the description of the DD bit in this section). This means that header buffer addresses are always word aligned."Right now, in ixgbe PMD we always setup Packet Buffer Address (PBA)and Header Buffer Address (HBA) to the same value:
buf_physaddr+RTE_PKTMBUF_HEADROOM
So when pirv_size==1, DD bit in RXD is always set to one by SW itself, and then SW considers that HW already done with it.
In other words, right now for ixgbe you can't use RX buffer that is not aligned on word boundary.So the advice would be, right now - don't set
priv_sizeto the odd value. As we don't support split header feature anyway, I think we can fix it just by always setting HBA in the RXD to zero.
Could you try the fix for ixgbe below?Same story with FVL, I believe.
KonstantinQuoted 9 lines
Interestingly this does not happen if we force the scattered rx path.
I assume the drivers have some expectations regarding the alignment of the
buf_addrin the mbuf and setting an odd private are size breaks this alignment in therte_pktmbuf_initfunction. If this is the case then one possible fix might be to enforce an alignment on the private area size.Best regards,
Martindrivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1183,7 +1183,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)/* populate the descriptors */ dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb)); - rxdp[i].read.hdr_addr = dma_addr; + rxdp[i].read.hdr_addr =0 ; rxdp[i].read.pkt_addr = dma_addr;}drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1414,7 +1414,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxe->mbuf = nmb; dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (nmb)); - rxdp->read.hdr_addr = dma_addr; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma_addr;/*drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1741,7 +1741,7 @@ next_desc: rxe->mbuf = nmb; rxm->data_off =RTE_PKTMBUF_HEADROOM ; - rxdp->read.hdr_addr = dma; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma; }else rxe->mbuf = NULL; @@ -3633,7 +3633,7 @@
ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq)
dma_addr=rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mbuf)); rxd = &rxq->rx_ring[i];drivers/net/ixgbe/ixgbe_rxtx.c +1
-1- rxd->read.hdr_addr = dma_addr; + rxd->read.hdr_addr =0 ; rxd->read.pkt_addr = dma_addr; rxe[i].mbuf = mbuf; }drivers/net/ixgbe/ixgbe_rxtx_vec.c +2
-0@@ -56,6 +56,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) RTE_PKTMBUF_HEADROOM);__m128i dma_addr0, dma_addr1; +const __m128i hba_msk =_mm_set_epi64x (0 ,UINT64_MAX ); + rxdp = rxq->rx_ring + rxq->rxrearm_start; /* Pull 'n' more MBUFs into the software ring */ @@ -108,6 +110,9 @@
ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)dma_addr0 = _mm_add_epi64(dma_addr0, hdr_room); dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);drivers/net/ixgbe/ixgbe_rxtx_vec.c +3
-0+ dma_addr0 =_mm_and_si128 (dma_addr0, hba_msk); + dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk); +/* flush desc with pa dma_addr */ _mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0);_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1);bash-4.2$ cat patch1 diff --git
a/drivers/net/ixgbe/ixgbe_rxtx.cb/drivers/net/ixgbe/ixgbe_rxtx.cindex a0c8847..94967c5 100644drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1183,7 +1183,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)/* populate the descriptors */ dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb)); - rxdp[i].read.hdr_addr = dma_addr; + rxdp[i].read.hdr_addr =0 ; rxdp[i].read.pkt_addr = dma_addr;}drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1414,7 +1414,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxe->mbuf = nmb; dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (nmb)); - rxdp->read.hdr_addr = dma_addr; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma_addr;/*drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1741,7 +1741,7 @@ next_desc: rxe->mbuf = nmb; rxm->data_off =RTE_PKTMBUF_HEADROOM ; - rxdp->read.hdr_addr = dma; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma; }else rxe->mbuf = NULL; @@ -3633,7 +3633,7 @@
ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq)
dma_addr=rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mbuf)); rxd = &rxq->rx_ring[i];drivers/net/ixgbe/ixgbe_rxtx.c +1
-1- rxd->read.hdr_addr = dma_addr; + rxd->read.hdr_addr =0 ; rxd->read.pkt_addr = dma_addr; rxe[i].mbuf = mbuf; }drivers/net/ixgbe/ixgbe_rxtx_vec.c +2
-0@@ -56,6 +56,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) RTE_PKTMBUF_HEADROOM);__m128i dma_addr0, dma_addr1; +const __m128i hba_msk =_mm_set_epi64x (0 ,UINT64_MAX ); + rxdp = rxq->rx_ring + rxq->rxrearm_start; /* Pull 'n' more MBUFs into the software ring */ @@ -108,6 +110,9 @@
ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)dma_addr0 = _mm_add_epi64(dma_addr0, hdr_room); dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);drivers/net/ixgbe/ixgbe_rxtx_vec.c +3
-0+ dma_addr0 =_mm_and_si128 (dma_addr0, hba_msk); + dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk); +/* flush desc with pa dma_addr */ _mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0);_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1);
Hi,
Quoted 50 lines · Konstantin
Quoted 44 lines
-----Original Message-----
From: Olivier MATZ [mailto:[email protected]]
Sent: Thursday, July 30, 2015 10:10 AM
To: Ananyev, Konstantin; Zhang, Helin; Martin Weiser
Cc: [email protected]
Subject: Re: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi Konstantin,
Quoted 32 lines · Konstantin
Hi Olivier,
Quoted 28 lines
-----Original Message-----
From: Olivier MATZ [mailto:[email protected]]
Sent: Thursday, July 30, 2015 9:12 AM
To: Zhang, Helin; Ananyev, Konstantin; Martin Weiser
Cc: [email protected]
Subject: Re: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi,
Quoted 7 lines · Helin
Hi Martin
Thank you very much for the good catch!
The similar situation in i40e, as explained by Konstantin.
As header split hasn't been supported by DPDK till now. It would be better to put the header address in RX descriptor to 0. But in the future, during header split enabling. We may need to pay extra attention to that. As at least x710 datasheet saidspecifically as below.
Quoted 1 line
"The header address should be set by the software to an even number (word aligned address)". We may need to find a way to
ensure that during mempool/mbuf allocation.
Indeed it would be good to force the
priv_sizeto be aligned.The
priv_sizecould be aligned automatically inrte_pktmbuf_pool_create(). The only possible problem I could see is that it would break applications that access to the data buffer by doing (sizeof(mbuf) + sizeof(priv)), which is probably not the best thing to do (I didn't find any applications like this in dpdk).Quoted 5 lines
Quoted 1 line
Might be just make
rte_pktmbuf_pool_create()fail if inputpriv_size%MIN_ALIGN!= 0?Hmm maybe it would break more applications: an odd
priv_sizeis probably rare, but apriv_sizethat is not aligned to 8 bytes is maybe more common.
Quoted 7 lines
My thought was that
rte_mempool_create()was just introduced in 2.1, so if we add extra requirement for the input parameter now -
there would be no ABI breakage, and not many people started to use it already. For me just seems a bit easier and more straightforward then silent alignment - user would not have wrong assumptions here.
Though if you think that a silent alignment would be more convenient for most users - I wouldn't insist.
Yes, I agree on the principle, but it depends whether this fix is integrated for 2.1 or not.
I think it may already be a bit late for that, especially as it is not a very critical bug.
Thomas, what do you think?
Olivier
Quoted 244 lines
Konstantin
Quoted 241 lines
It's maybe safer to align the size transparently?
Regards,
OlivierQuoted 233 lines
Quoted 8 lines
For applications that directly use
rte_mempool_create()instead ofrte_pktmbuf_pool_create(), we could add a check using an assert inrte_pktmbuf_init()and some words in the documentation.The question is: what should be the proper alignment? I would say at least 8 bytes, but maybe
cache_alignedis an option too.8 bytes seems enough to me.
Konstantin
Quoted 219 lines
Regards,
OlivierQuoted 214 lines
Regards,
HelinQuoted 210 lines
-----Original Message-----
From: Ananyev, Konstantin
Sent: Wednesday, July 29, 2015 11:12 AM
To: Martin Weiser; Zhang, Helin; [email protected]
Cc: [email protected]
Subject: RE: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi Martin,
Quoted 10 lines
-----Original Message-----
From: dev [mailto:[email protected]] On Behalf Of Martin Weiser
Sent: Wednesday, July 29, 2015 4:07 PM
To: Zhang, Helin; [email protected]
Cc: [email protected]
Subject: [dpdk-dev] Issue with non-scattered rx in ixgbe and i40e when mbuf private area size is oddHi Helin, Hi Olivier,
Quoted 9 lines
we are seeing an issue with the ixgbe and i40e drivers which we could track down to our setting of the private area size of the mbufs. The issue can be easily reproduced with the l2fwd example application when a small modification is done: just set the
priv_sizeparameter in the call to therte_pktmbuf_pool_createfunction to an odd number like
1. In our tests this causes every call torte_eth_rx_burstto return 32 (which is the setting ofnb_pkts) nonsense mbufs although no packets are received on the interface and the hardware counters do not report any received packets.From Niantic datasheet:
"7.1.6.1 Advanced Receive Descriptors — Read Format Table 7-15 lists the advanced receive descriptor programming by the software. The ... Packet Buffer Address (64)
This is the physical address of the packet buffer. The lowest bit is A0 (LSB of the address).
Header Buffer Address (64)
The physical address of the header buffer with the lowest bit being Descriptor Done (DD).
When a packet spans in multiple descriptors, the header buffer address is used only on the first descriptor. During the programming phase, software must set the DD bit to zero (see the description of the DD bit in this section). This means that header buffer addresses are always word aligned."Right now, in ixgbe PMD we always setup Packet Buffer Address (PBA)and Header Buffer Address (HBA) to the same value:
buf_physaddr+RTE_PKTMBUF_HEADROOM
So when pirv_size==1, DD bit in RXD is always set to one by SW itself, and then SW considers that HW already done with it.
In other words, right now for ixgbe you can't use RX buffer that is not aligned on word boundary.So the advice would be, right now - don't set
priv_sizeto the odd value. As we don't support split header feature anyway, I think we can fix it just by always setting HBA in the RXD to zero.
Could you try the fix for ixgbe below?Same story with FVL, I believe.
KonstantinQuoted 9 lines
Interestingly this does not happen if we force the scattered rx path.
I assume the drivers have some expectations regarding the alignment of the
buf_addrin the mbuf and setting an odd private are size breaks this alignment in therte_pktmbuf_initfunction. If this is the case then one possible fix might be to enforce an alignment on the private area size.Best regards,
Martindrivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1183,7 +1183,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)/* populate the descriptors */ dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb)); - rxdp[i].read.hdr_addr = dma_addr; + rxdp[i].read.hdr_addr =0 ; rxdp[i].read.pkt_addr = dma_addr;}drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1414,7 +1414,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxe->mbuf = nmb; dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (nmb)); - rxdp->read.hdr_addr = dma_addr; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma_addr;/*drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1741,7 +1741,7 @@ next_desc: rxe->mbuf = nmb; rxm->data_off =RTE_PKTMBUF_HEADROOM ; - rxdp->read.hdr_addr = dma; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma; }else rxe->mbuf = NULL; @@ -3633,7 +3633,7 @@
ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq)
dma_addr=rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mbuf)); rxd = &rxq->rx_ring[i];drivers/net/ixgbe/ixgbe_rxtx.c +1
-1- rxd->read.hdr_addr = dma_addr; + rxd->read.hdr_addr =0 ; rxd->read.pkt_addr = dma_addr; rxe[i].mbuf = mbuf; }drivers/net/ixgbe/ixgbe_rxtx_vec.c +2
-0@@ -56,6 +56,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) RTE_PKTMBUF_HEADROOM);__m128i dma_addr0, dma_addr1; +const __m128i hba_msk =_mm_set_epi64x (0 ,UINT64_MAX ); + rxdp = rxq->rx_ring + rxq->rxrearm_start; /* Pull 'n' more MBUFs into the software ring */ @@ -108,6 +110,9 @@
ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)dma_addr0 = _mm_add_epi64(dma_addr0, hdr_room); dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);drivers/net/ixgbe/ixgbe_rxtx_vec.c +3
-0+ dma_addr0 =_mm_and_si128 (dma_addr0, hba_msk); + dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk); +/* flush desc with pa dma_addr */ _mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0);_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1);bash-4.2$ cat patch1 diff --git
a/drivers/net/ixgbe/ixgbe_rxtx.cb/drivers/net/ixgbe/ixgbe_rxtx.cindex a0c8847..94967c5 100644drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1183,7 +1183,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)/* populate the descriptors */ dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb)); - rxdp[i].read.hdr_addr = dma_addr; + rxdp[i].read.hdr_addr =0 ; rxdp[i].read.pkt_addr = dma_addr;}drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1414,7 +1414,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxe->mbuf = nmb; dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (nmb)); - rxdp->read.hdr_addr = dma_addr; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma_addr;/*drivers/net/ixgbe/ixgbe_rxtx.c +1
-1@@ -1741,7 +1741,7 @@ next_desc: rxe->mbuf = nmb; rxm->data_off =RTE_PKTMBUF_HEADROOM ; - rxdp->read.hdr_addr = dma; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma; }else rxe->mbuf = NULL; @@ -3633,7 +3633,7 @@
ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq)
dma_addr=rte_cpu_to_le_64(RTE_MBUF_DATA_DMA_ADDR_DEFAULT(mbuf)); rxd = &rxq->rx_ring[i];drivers/net/ixgbe/ixgbe_rxtx.c +1
-1- rxd->read.hdr_addr = dma_addr; + rxd->read.hdr_addr =0 ; rxd->read.pkt_addr = dma_addr; rxe[i].mbuf = mbuf; }drivers/net/ixgbe/ixgbe_rxtx_vec.c +2
-0@@ -56,6 +56,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) RTE_PKTMBUF_HEADROOM);__m128i dma_addr0, dma_addr1; +const __m128i hba_msk =_mm_set_epi64x (0 ,UINT64_MAX ); + rxdp = rxq->rx_ring + rxq->rxrearm_start; /* Pull 'n' more MBUFs into the software ring */ @@ -108,6 +110,9 @@
ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq)dma_addr0 = _mm_add_epi64(dma_addr0, hdr_room); dma_addr1 = _mm_add_epi64(dma_addr1, hdr_room);drivers/net/ixgbe/ixgbe_rxtx_vec.c +3
-0+ dma_addr0 =_mm_and_si128 (dma_addr0, hba_msk); + dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk); +/* flush desc with pa dma_addr */ _mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0);_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1);
2015-07-30 13:22, Olivier MATZ:
Quoted 36 lines · Konstantin
Quoted 26 lines
From: Olivier MATZ [mailto:[email protected]]
Quoted 19 lines · Konstantin
Quoted 18 lines
From: Olivier MATZ [mailto:[email protected]]
Quoted 15 lines · Helin
Quoted 3 lines
The similar situation in i40e, as explained by Konstantin.
As header split hasn't been supported by DPDK till now. It would be better to put the header address in RX descriptor to 0. But in the future, during header split enabling. We may need to pay extra attention to that. As at least x710 datasheet saidspecifically as below.
Quoted 1 line
"The header address should be set by the software to an even number (word aligned address)". We may need to find a way to
ensure that during mempool/mbuf allocation.
Indeed it would be good to force the
priv_sizeto be aligned.The
priv_sizecould be aligned automatically inrte_pktmbuf_pool_create(). The only possible problem I could see is that it would break applications that access to the data buffer by doing (sizeof(mbuf) + sizeof(priv)), which is probably not the best thing to do (I didn't find any applications like this in dpdk).Quoted 5 lines
Quoted 1 line
Might be just make
rte_pktmbuf_pool_create()fail if inputpriv_size%MIN_ALIGN!= 0?Hmm maybe it would break more applications: an odd
priv_sizeis probably rare, but apriv_sizethat is not aligned to 8 bytes is maybe more common.Quoted 7 lines
My thought was that
rte_mempool_create()was just introduced in 2.1, so if we add extra requirement for the input parameter now -
there would be no ABI breakage, and not many people started to use it already. For me just seems a bit easier and more straightforward then silent alignment - user would not have wrong assumptions here.
Though if you think that a silent alignment would be more convenient for most users - I wouldn't insist.
Quoted 6 lines
Yes, I agree on the principle, but it depends whether this fix is integrated for 2.1 or not.
I think it may already be a bit late for that, especially as it is not a very critical bug.Thomas, what do you think?
It is a fix.
Adding a doc comment, an assert and an alignment constraint or a new automatic alignment in the not yet released function shouldn't hurt.
A patch would be welcome for 2.1. Thanks
PATCH 1/1 mbuf: enforce alignment of mbuf private area
It looks better to have a data buffer address that is aligned to 8 bytes. This is the case when there is no mbuf private area, but if there is one, the alignment depends on the size of this area that is located between the mbuf structure and the data buffer.
Indeed, some drivers expects to have the buffer address aligned to an even address, and moreover an unaligned buffer may impact the performance when accessing to network headers.
Add a check in rte_pktmbuf_pool_create() to verify the alignment constraint before creating the mempool. For applications that use the alternative way (direct call to rte_mempool_create), also add an assertion in rte_pktmbuf_init().
By the way, also add the MBUF log type.
--- lib/librte_eal/common/include/rte_log.h | 1 + lib/librte_mbuf/rte_mbuf.c | 8 +++++++- lib/librte_mbuf/rte_mbuf.h | 7 +++++-- 3 files changed, 13 insertions(+), 3 deletions(-)
lib/librte_eal/common/include/rte_log.h +1 -0
@@ -77,6 +77,7 @@ extern struct rte_logs rte_logs;#define RTE_LOGTYPE_PORT 0x00002000/**< Log related to port. */ #define RTE_LOGTYPE_TABLE 0x00004000/**< Log related to table. */ #define RTE_LOGTYPE_PIPELINE 0x00008000/**< Log related to pipeline. */ +#define RTE_LOGTYPE_MBUF 0x00010000/**< Log related to mbuf. */ /* these log types can be used in an application */ #define RTE_LOGTYPE_USER1 0x01000000/**< User-defined log type 1. */
lib/librte_mbuf/rte_mbuf.c +7 -1
@@ -125,6 +125,7 @@ rte_pktmbuf_init(struct rte_mempool *mp, mbuf_size =sizeof (struct rte_mbuf ) + priv_size; buf_len =rte_pktmbuf_data_room_size (mp); +RTE_MBUF_ASSERT ((priv_size & (RTE_MBUF_PRIV_ALIGN -1 )) ==0 );RTE_MBUF_ASSERT (mp->elt_size >= mbuf_size);RTE_MBUF_ASSERT (buf_len <=UINT16_MAX );
@@ -154,7 +155,12 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,struct rte_pktmbuf_pool_private mbp_priv;unsigned elt_size; - +if ((priv_size & (RTE_MBUF_PRIV_ALIGN -1 )) !=0 ) { +RTE_LOG (ERR ,MBUF ,"mbuf priv_size=%u is not aligned\n" , + priv_size); + rte_errno =EINVAL ; +return NULL ; + } elt_size =sizeof (struct rte_mbuf ) + (unsigned )priv_size + (unsigned )data_room_size; mbp_priv.mbuf_data_room_size = data_room_size;
lib/librte_mbuf/rte_mbuf.h +5 -2
@@ -698,6 +698,9 @@ extern "C" { RTE_PTYPE_INNER_L4_MASK))#endif /* RTE_NEXT_ABI */ +/** Alignment constraint of mbuf private area. */ +#define RTE_MBUF_PRIV_ALIGN 8 +/** * Get the name of a RX offload flag *
@@ -1238,7 +1241,7 @@ void rte_pktmbuf_pool_init(struct rte_mempool *mp, void *opaque_arg);* details. * @param priv_size * Size of application private are between the rte_mbuf structure -* and the data buffer. +* and the data buffer. This value must be aligned to RTE_MBUF_PRIV_ALIGN. * @param data_room_size * Size of data buffer in each mbuf, including RTE_PKTMBUF_HEADROOM. * @param socket_id
@@ -1250,7 +1253,7 @@ void rte_pktmbuf_pool_init(struct rte_mempool *mp, void *opaque_arg);* with rte_errno set appropriately. Possible rte_errno values include: * - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure * - E_RTE_SECONDARY - function was called from a secondary process instance -* - EINVAL - cache size provided is too large +* - EINVAL - cache size provided is too large, or priv_size is not aligned. * - ENOSPC - the maximum number of memzones has already been allocated * - EEXIST - a memzone with the same name already exists * - ENOMEM - no appropriate memory area found in which to create memzone
Signature · 1 line
2.1.4
Re: [PATCH] mbuf: enforce alignment of mbuf private area
Hi Olivier,
If fails to compile for me:
/local/kananye1/dpdk.org-mbprv1/lib/librte_mbuf/rte_mbuf.c: In function ârte_pktmbuf_pool_createâ:
/local/kananye1/dpdk.org-mbprv1/lib/librte_mbuf/rte_mbuf.c:161:3: error: ârte_errnoâ undeclared (first use in this function)
rte_errno = EINVAL;
^
/local/kananye1/dpdk.org-mbprv1/lib/librte_mbuf/rte_mbuf.c:161:3: note: each undeclared identifier is reported only once for each function it appears in
I had to add:
lib/librte_mbuf/rte_mbuf.c +1 -0
@@ -58,6 +58,7 @@#include <rte_mbuf.h> #include <rte_string_fns.h> #include <rte_hexdump.h> +#include <rte_errno.h> /* * ctrlmbuf constructor, given as a callback function to
Apart from that - looks good to me.
Konstantin
Quoted 102 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Thursday, July 30, 2015 2:56 PM
To: [email protected]
Cc: Ananyev, Konstantin; [email protected]; Zhang, Helin; [email protected]; [email protected]
Subject: [PATCH] mbuf: enforce alignment of mbuf private areaIt looks better to have a data buffer address that is aligned to 8 bytes. This is the case when there is no mbuf private area, but if there is one, the alignment depends on the size of this area that is located between the mbuf structure and the data buffer.
Indeed, some drivers expects to have the buffer address aligned to an even address, and moreover an unaligned buffer may impact the performance when accessing to network headers.
Add a check in
rte_pktmbuf_pool_create()to verify the alignment constraint before creating the mempool. For applications that use the alternative way (direct call torte_mempool_create), also add an assertion inrte_pktmbuf_init().By the way, also add the MBUF log type.
Signed-off-by Olivier Matz <[email protected]>--- lib/librte_eal/common/include/rte_log.h | 1 + lib/librte_mbuf/rte_mbuf.c | 8 +++++++- lib/librte_mbuf/rte_mbuf.h | 7 +++++-- 3 files changed, 13 insertions(+), 3 deletions(-)lib/librte_eal/common/include/rte_log.h +1
-0@@ -77,6 +77,7 @@ extern struct rte_logs rte_logs;#define RTE_LOGTYPE_PORT 0x00002000/**< Log related to port. */ #define RTE_LOGTYPE_TABLE 0x00004000/**< Log related to table. */ #define RTE_LOGTYPE_PIPELINE 0x00008000/**< Log related to pipeline. */ +#define RTE_LOGTYPE_MBUF 0x00010000/**< Log related to mbuf. */ /* these log types can be used in an application */ #define RTE_LOGTYPE_USER1 0x01000000/**< User-defined log type 1. */ lib/librte_mbuf/rte_mbuf.c +7
-1@@ -125,6 +125,7 @@ rte_pktmbuf_init(struct rte_mempool *mp, mbuf_size =sizeof (struct rte_mbuf ) + priv_size; buf_len =rte_pktmbuf_data_room_size (mp); +RTE_MBUF_ASSERT ((priv_size & (RTE_MBUF_PRIV_ALIGN -1 )) ==0 );RTE_MBUF_ASSERT (mp->elt_size >= mbuf_size);RTE_MBUF_ASSERT (buf_len <=UINT16_MAX );@@ -154,7 +155,12 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,struct rte_pktmbuf_pool_private mbp_priv;unsigned elt_size; - +if ((priv_size & (RTE_MBUF_PRIV_ALIGN -1 )) !=0 ) { +RTE_LOG (ERR ,MBUF ,"mbuf priv_size=%u is not aligned\n" , + priv_size); + rte_errno =EINVAL ; +return NULL ; + } elt_size =sizeof (struct rte_mbuf ) + (unsigned )priv_size + (unsigned )data_room_size; mbp_priv.mbuf_data_room_size = data_room_size;lib/librte_mbuf/rte_mbuf.h +5
-3@@ -698,6 +698,9 @@ extern "C" { RTE_PTYPE_INNER_L4_MASK))#endif /* RTE_NEXT_ABI */ +/** Alignment constraint of mbuf private area. */ +#define RTE_MBUF_PRIV_ALIGN 8 +/** * Get the name of a RX offload flag * @@ -1238,7 +1241,7 @@ void rte_pktmbuf_pool_init(struct rte_mempool *mp, void *opaque_arg);* details. * @param priv_size * Size of application private are between the rte_mbuf structure -* and the data buffer. +* and the data buffer. This value must be aligned to RTE_MBUF_PRIV_ALIGN. * @param data_room_size * Size of data buffer in each mbuf, including RTE_PKTMBUF_HEADROOM. * @param socket_id @@ -1250,7 +1253,7 @@ void rte_pktmbuf_pool_init(struct rte_mempool *mp, void *opaque_arg);* with rte_errno set appropriately. Possible rte_errno values include: * - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure * - E_RTE_SECONDARY - function was called from a secondary process instance -* - EINVAL - cache size provided is too large +* - EINVAL - cache size provided is too large, or priv_size is not aligned. * - ENOSPC - the maximum number of memzones has already been allocated * - EEXIST - a memzone with the same name already exists * - ENOMEM - no appropriate memory area found in which to create memzone -- 2.1.4
Re: [PATCH] mbuf: enforce alignment of mbuf private area
Quoted 5 lines · Konstantin
Hi Olivier,
If fails to compile for me:
Quoted 7 lines
/local/kananye1/dpdk.org-mbprv1/lib/librte_mbuf/rte_mbuf.c: In function ârte_pktmbuf_pool_createâ:
/local/kananye1/dpdk.org-mbprv1/lib/librte_mbuf/rte_mbuf.c:161:3: error: ârte_errnoâ undeclared (first use in this function)rte_errno = EINVAL; ^/local/kananye1/dpdk.org-mbprv1/lib/librte_mbuf/rte_mbuf.c:161:3: note: each undeclared identifier is reported only once for each function it appears in
I had to add:
Sorry I had the same error but I forgot to squash the fix... :/
I'm sending a v2
Quoted 120 lines
lib/librte_mbuf/rte_mbuf.c +1
-0@@ -58,6 +58,7 @@#include <rte_mbuf.h> #include <rte_string_fns.h> #include <rte_hexdump.h> +#include <rte_errno.h> /* * ctrlmbuf constructor, given as a callback function to Apart from that - looks good to me.
KonstantinQuoted 102 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Thursday, July 30, 2015 2:56 PM
To: [email protected]
Cc: Ananyev, Konstantin; [email protected]; Zhang, Helin; [email protected]; [email protected]
Subject: [PATCH] mbuf: enforce alignment of mbuf private areaIt looks better to have a data buffer address that is aligned to 8 bytes. This is the case when there is no mbuf private area, but if there is one, the alignment depends on the size of this area that is located between the mbuf structure and the data buffer.
Indeed, some drivers expects to have the buffer address aligned to an even address, and moreover an unaligned buffer may impact the performance when accessing to network headers.
Add a check in
rte_pktmbuf_pool_create()to verify the alignment constraint before creating the mempool. For applications that use the alternative way (direct call torte_mempool_create), also add an assertion inrte_pktmbuf_init().By the way, also add the MBUF log type.
Signed-off-by Olivier Matz <[email protected]>--- lib/librte_eal/common/include/rte_log.h | 1 + lib/librte_mbuf/rte_mbuf.c | 8 +++++++- lib/librte_mbuf/rte_mbuf.h | 7 +++++-- 3 files changed, 13 insertions(+), 3 deletions(-)lib/librte_eal/common/include/rte_log.h +1
-0@@ -77,6 +77,7 @@ extern struct rte_logs rte_logs;#define RTE_LOGTYPE_PORT 0x00002000/**< Log related to port. */ #define RTE_LOGTYPE_TABLE 0x00004000/**< Log related to table. */ #define RTE_LOGTYPE_PIPELINE 0x00008000/**< Log related to pipeline. */ +#define RTE_LOGTYPE_MBUF 0x00010000/**< Log related to mbuf. */ /* these log types can be used in an application */ #define RTE_LOGTYPE_USER1 0x01000000/**< User-defined log type 1. */ lib/librte_mbuf/rte_mbuf.c +7
-1@@ -125,6 +125,7 @@ rte_pktmbuf_init(struct rte_mempool *mp, mbuf_size =sizeof (struct rte_mbuf ) + priv_size; buf_len =rte_pktmbuf_data_room_size (mp); +RTE_MBUF_ASSERT ((priv_size & (RTE_MBUF_PRIV_ALIGN -1 )) ==0 );RTE_MBUF_ASSERT (mp->elt_size >= mbuf_size);RTE_MBUF_ASSERT (buf_len <=UINT16_MAX );@@ -154,7 +155,12 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,struct rte_pktmbuf_pool_private mbp_priv;unsigned elt_size; - +if ((priv_size & (RTE_MBUF_PRIV_ALIGN -1 )) !=0 ) { +RTE_LOG (ERR ,MBUF ,"mbuf priv_size=%u is not aligned\n" , + priv_size); + rte_errno =EINVAL ; +return NULL ; + } elt_size =sizeof (struct rte_mbuf ) + (unsigned )priv_size + (unsigned )data_room_size; mbp_priv.mbuf_data_room_size = data_room_size;lib/librte_mbuf/rte_mbuf.h +5
-3@@ -698,6 +698,9 @@ extern "C" { RTE_PTYPE_INNER_L4_MASK))#endif /* RTE_NEXT_ABI */ +/** Alignment constraint of mbuf private area. */ +#define RTE_MBUF_PRIV_ALIGN 8 +/** * Get the name of a RX offload flag * @@ -1238,7 +1241,7 @@ void rte_pktmbuf_pool_init(struct rte_mempool *mp, void *opaque_arg);* details. * @param priv_size * Size of application private are between the rte_mbuf structure -* and the data buffer. +* and the data buffer. This value must be aligned to RTE_MBUF_PRIV_ALIGN. * @param data_room_size * Size of data buffer in each mbuf, including RTE_PKTMBUF_HEADROOM. * @param socket_id @@ -1250,7 +1253,7 @@ void rte_pktmbuf_pool_init(struct rte_mempool *mp, void *opaque_arg);* with rte_errno set appropriately. Possible rte_errno values include: * - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure * - E_RTE_SECONDARY - function was called from a secondary process instance -* - EINVAL - cache size provided is too large +* - EINVAL - cache size provided is too large, or priv_size is not aligned. * - ENOSPC - the maximum number of memzones has already been allocated * - EEXIST - a memzone with the same name already exists * - ENOMEM - no appropriate memory area found in which to create memzone -- 2.1.4
Re: [PATCH] mbuf: enforce alignment of mbuf private area
In reply to Olivier MatzQuoted 50 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Thursday, July 30, 2015 6:56 AM
To: [email protected]
Cc: Ananyev, Konstantin; [email protected]; Zhang, Helin; [email protected]; [email protected]
Subject: [PATCH] mbuf: enforce alignment of mbuf private areaIt looks better to have a data buffer address that is aligned to
8 bytes. This is the case when there is no mbuf private area, but if there is one, the alignment depends on the size of this area that is located between the mbuf structure and the data buffer.Indeed, some drivers expects to have the buffer address aligned to an even address, and moreover an unaligned buffer may impact the performance when accessing to network headers.
Add a check in
rte_pktmbuf_pool_create()to verify the alignment constraint before creating the mempool. For applications that use the alternative way (direct call torte_mempool_create), also add an assertion inrte_pktmbuf_init().By the way, also add the MBUF log type.
Signed-off-by Olivier Matz <[email protected]>--- lib/librte_eal/common/include/rte_log.h | 1 + lib/librte_mbuf/rte_mbuf.c | 8 +++++++- lib/librte_mbuf/rte_mbuf.h | 7 +++++-- 3 files changed, 13 insertions(+), 3 deletions(-)lib/librte_eal/common/include/rte_log.h +1
-0@@ -77,6 +77,7 @@ extern struct rte_logs rte_logs;#define RTE_LOGTYPE_PORT 0x00002000/**< Log related to port. */ #define RTE_LOGTYPE_TABLE 0x00004000/**< Log related to table. */ #define RTE_LOGTYPE_PIPELINE 0x00008000/**< Log related to pipeline. */ +#define RTE_LOGTYPE_MBUF 0x00010000/**< Log related to mbuf. */ /* these log types can be used in an application */ #define RTE_LOGTYPE_USER1 0x01000000/**< User-defined log type 1. */ lib/librte_mbuf/rte_mbuf.c index renamed from lib/librte_mbuf/rte_mbuf.c +0
-04320dd4..a1ddbb3 100644
lib/librte_mbuf/rte_mbuf.c rte_pktmbuf_init(struct rte_mempool *mp, · line 128
Quoted 4 lines
lib/librte_mbuf/rte_mbuf.c +1
-0@@ -125,6 +125,7 @@ rte_pktmbuf_init(struct rte_mempool *mp, mbuf_size =sizeof (struct rte_mbuf ) + priv_size; buf_len =rte_pktmbuf_data_room_size (mp); +RTE_MBUF_ASSERT ((priv_size & (RTE_MBUF_PRIV_ALIGN -1 )) ==0 );
Using RTE_ALIGN() could be more readable?
lib/librte_mbuf/rte_mbuf.c rte_pktmbuf_pool_create(const char *name, unsigned · line 159
Quoted 10 lines
lib/librte_mbuf/rte_mbuf.c +1
-1RTE_MBUF_ASSERT (mp->elt_size >= mbuf_size);RTE_MBUF_ASSERT (buf_len <=UINT16_MAX );@@ -154,7 +155,12 @@ rte_pktmbuf_pool_create(const char *name, unsigned n, struct rte_pktmbuf_pool_private mbp_priv;unsigned elt_size; - +if ((priv_size & (RTE_MBUF_PRIV_ALIGN -1 )) !=0 ) {
Using RTE_ALIGN() could be more readable?
Quoted 49 lines
lib/librte_mbuf/rte_mbuf.c +5
-0+RTE_LOG (ERR ,MBUF ,"mbuf priv_size=%u is not aligned\n" , + priv_size); + rte_errno =EINVAL ; +return NULL ; + } elt_size =sizeof (struct rte_mbuf ) + (unsigned )priv_size + (unsigned )data_room_size;mbp_priv.mbuf_data_room_size =
data_room_size; diff --gita/lib/librte_mbuf/rte_mbuf.hb/lib/librte_mbuf/rte_mbuf.hindex 010b32d..c3b8c98 100644lib/librte_mbuf/rte_mbuf.h +0
-0@@ -698,6 +698,9 @@ extern "C" {
RTE_PTYPE_INNER_L4_MASK)) #endif /*RTE_NEXT_ABI*/lib/librte_mbuf/rte_mbuf.h +4
-1+/** Alignment constraint of mbuf private area. */ #define +RTE_MBUF_PRIV_ALIGN 8 +/** * Get the name of a RX offload flag * @@ -1238,7 +1241,7 @@ void rte_pktmbuf_pool_init(struct rte_mempool *mp, void *opaque_arg); * details. * @param priv_size * Size of application private are between the rte_mbuf structure - * and the data buffer. + * and the data buffer. This value must be aligned to
RTE_MBUF_PRIV_ALIGN.
* @paramdata_room_size
* Size of data buffer in each mbuf, includingRTE_PKTMBUF_HEADROOM.
* @paramsocket_idlib/librte_mbuf/rte_mbuf.h +0
-0@@ -1250,7 +1253,7 @@ void rte_pktmbuf_pool_init(struct rte_mempool *mp, void *opaque_arg); * with rte_errno set appropriately. Possible rte_errno values include: * - E_RTE_NO_CONFIG - function could not get pointer to rte_configstructure
* -E_RTE_SECONDARY- function was called from a secondary process
instance- * - EINVAL - cache size provided is too large + * - EINVAL - cache size provided is too large, or priv_size is not aligned. * - ENOSPC - the maximum number of memzones has already beenallocated
* - EEXIST - a memzone with the same name already exists
* - ENOMEM - no appropriate memory area found in which to create
memzone
--
2.1.4
Re: [PATCH] mbuf: enforce alignment of mbuf private area
Quoted 59 lines · Helin
Quoted 50 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Thursday, July 30, 2015 6:56 AM
To: [email protected]
Cc: Ananyev, Konstantin; [email protected]; Zhang, Helin; [email protected]; [email protected]
Subject: [PATCH] mbuf: enforce alignment of mbuf private areaIt looks better to have a data buffer address that is aligned to
8 bytes. This is the case when there is no mbuf private area, but if there is one, the alignment depends on the size of this area that is located between the mbuf structure and the data buffer.Indeed, some drivers expects to have the buffer address aligned to an even address, and moreover an unaligned buffer may impact the performance when accessing to network headers.
Add a check in
rte_pktmbuf_pool_create()to verify the alignment constraint before creating the mempool. For applications that use the alternative way (direct call torte_mempool_create), also add an assertion inrte_pktmbuf_init().By the way, also add the MBUF log type.
Signed-off-by Olivier Matz <[email protected]>--- lib/librte_eal/common/include/rte_log.h | 1 + lib/librte_mbuf/rte_mbuf.c | 8 +++++++- lib/librte_mbuf/rte_mbuf.h | 7 +++++-- 3 files changed, 13 insertions(+), 3 deletions(-)lib/librte_eal/common/include/rte_log.h +1
-0@@ -77,6 +77,7 @@ extern struct rte_logs rte_logs;#define RTE_LOGTYPE_PORT 0x00002000/**< Log related to port. */ #define RTE_LOGTYPE_TABLE 0x00004000/**< Log related to table. */ #define RTE_LOGTYPE_PIPELINE 0x00008000/**< Log related to pipeline. */ +#define RTE_LOGTYPE_MBUF 0x00010000/**< Log related to mbuf. */ /* these log types can be used in an application */ #define RTE_LOGTYPE_USER1 0x01000000/**< User-defined log type 1. */ lib/librte_mbuf/rte_mbuf.c index renamed from lib/librte_mbuf/rte_mbuf.c +0
-04320dd4..a1ddbb3 100644
lib/librte_mbuf/rte_mbuf.c rte_pktmbuf_init(struct rte_mempool *mp, · line 128
Quoted 4 lines
lib/librte_mbuf/rte_mbuf.c +1
-0@@ -125,6 +125,7 @@ rte_pktmbuf_init(struct rte_mempool *mp, mbuf_size =sizeof (struct rte_mbuf ) + priv_size; buf_len =rte_pktmbuf_data_room_size (mp); +RTE_MBUF_ASSERT ((priv_size & (RTE_MBUF_PRIV_ALIGN -1 )) ==0 );Using
RTE_ALIGN()could be more readable?Quoted 3 lines
lib/librte_mbuf/rte_mbuf.c +0
-0RTE_MBUF_ASSERT (mp->elt_size >= mbuf_size);RTE_MBUF_ASSERT (buf_len <=UINT16_MAX );
Quoted 8 lines
lib/librte_mbuf/rte_mbuf.c rte_pktmbuf_pool_create(const char *name, unsigned · line 159
Quoted 7 lines
lib/librte_mbuf/rte_mbuf.c +1
-1@@ -154,7 +155,12 @@ rte_pktmbuf_pool_create(const char *name, unsigned n, struct rte_pktmbuf_pool_private mbp_priv;unsigned elt_size; - +if ((priv_size & (RTE_MBUF_PRIV_ALIGN -1 )) !=0 ) {Using
RTE_ALIGN()could be more readable?
Will do, thanks for commenting.
Quoted 51 lines
Quoted 50 lines
lib/librte_mbuf/rte_mbuf.c +5
-0+RTE_LOG (ERR ,MBUF ,"mbuf priv_size=%u is not aligned\n" , + priv_size); + rte_errno =EINVAL ; +return NULL ; + } elt_size =sizeof (struct rte_mbuf ) + (unsigned )priv_size + (unsigned )data_room_size;mbp_priv.mbuf_data_room_size =
data_room_size; diff --gita/lib/librte_mbuf/rte_mbuf.hb/lib/librte_mbuf/rte_mbuf.hindex 010b32d..c3b8c98 100644lib/librte_mbuf/rte_mbuf.h +0
-0@@ -698,6 +698,9 @@ extern "C" {
RTE_PTYPE_INNER_L4_MASK)) #endif /*RTE_NEXT_ABI*/lib/librte_mbuf/rte_mbuf.h +4
-1+/** Alignment constraint of mbuf private area. */ #define +RTE_MBUF_PRIV_ALIGN 8 +/** * Get the name of a RX offload flag * @@ -1238,7 +1241,7 @@ void rte_pktmbuf_pool_init(struct rte_mempool *mp, void *opaque_arg); * details. * @param priv_size * Size of application private are between the rte_mbuf structure - * and the data buffer. + * and the data buffer. This value must be aligned to
RTE_MBUF_PRIV_ALIGN.
* @paramdata_room_size
* Size of data buffer in each mbuf, includingRTE_PKTMBUF_HEADROOM.
* @paramsocket_idlib/librte_mbuf/rte_mbuf.h +0
-0@@ -1250,7 +1253,7 @@ void rte_pktmbuf_pool_init(struct rte_mempool *mp, void *opaque_arg); * with rte_errno set appropriately. Possible rte_errno values include: * - E_RTE_NO_CONFIG - function could not get pointer to rte_configstructure
* -E_RTE_SECONDARY- function was called from a secondary process
instance
- * - EINVAL - cache size provided is too large
+ * - EINVAL - cache size provided is too large, orpriv_sizeis not aligned.
* - ENOSPC - the maximum number of memzones has already been
allocated
* - EEXIST - a memzone with the same name already exists
* - ENOMEM - no appropriate memory area found in which to create
memzone
--
2.1.4
PATCH v2 1/1 mbuf: enforce alignment of mbuf private area
In reply to Olivier MatzIt looks better to have a data buffer address that is aligned to 8 bytes. This is the case when there is no mbuf private area, but if there is one, the alignment depends on the size of this area that is located between the mbuf structure and the data buffer.
Indeed, some drivers expects to have the buffer address aligned to an even address, and moreover an unaligned buffer may impact the performance when accessing to network headers.
Add a check in rte_pktmbuf_pool_create() to verify the alignment constraint before creating the mempool. For applications that use the alternative way (direct call to rte_mempool_create), also add an assertion in rte_pktmbuf_init().
By the way, also add the MBUF log type.
--- lib/librte_eal/common/include/rte_log.h | 1 + lib/librte_mbuf/rte_mbuf.c | 9 ++++++++- lib/librte_mbuf/rte_mbuf.h | 7 +++++-- 3 files changed, 14 insertions(+), 3 deletions(-)
lib/librte_eal/common/include/rte_log.h +1 -0
@@ -77,6 +77,7 @@ extern struct rte_logs rte_logs;#define RTE_LOGTYPE_PORT 0x00002000/**< Log related to port. */ #define RTE_LOGTYPE_TABLE 0x00004000/**< Log related to table. */ #define RTE_LOGTYPE_PIPELINE 0x00008000/**< Log related to pipeline. */ +#define RTE_LOGTYPE_MBUF 0x00010000/**< Log related to mbuf. */ /* these log types can be used in an application */ #define RTE_LOGTYPE_USER1 0x01000000/**< User-defined log type 1. */
lib/librte_mbuf/rte_mbuf.c +8 -1
@@ -58,6 +58,7 @@#include <rte_mbuf.h> #include <rte_string_fns.h> #include <rte_hexdump.h> +#include <rte_errno.h> /* * ctrlmbuf constructor, given as a callback function to
@@ -125,6 +126,7 @@ rte_pktmbuf_init(struct rte_mempool *mp, mbuf_size =sizeof (struct rte_mbuf ) + priv_size; buf_len =rte_pktmbuf_data_room_size (mp); +RTE_MBUF_ASSERT (RTE_ALIGN (priv_size,RTE_MBUF_PRIV_ALIGN ) == priv_size);RTE_MBUF_ASSERT (mp->elt_size >= mbuf_size);RTE_MBUF_ASSERT (buf_len <=UINT16_MAX );
@@ -154,7 +156,12 @@ rte_pktmbuf_pool_create(const char *name, unsigned n,struct rte_pktmbuf_pool_private mbp_priv;unsigned elt_size; - +if (RTE_ALIGN (priv_size,RTE_MBUF_PRIV_ALIGN ) != priv_size) { +RTE_LOG (ERR ,MBUF ,"mbuf priv_size=%u is not aligned\n" , + priv_size); + rte_errno =EINVAL ; +return NULL ; + } elt_size =sizeof (struct rte_mbuf ) + (unsigned )priv_size + (unsigned )data_room_size; mbp_priv.mbuf_data_room_size = data_room_size;
lib/librte_mbuf/rte_mbuf.h +5 -2
@@ -698,6 +698,9 @@ extern "C" { RTE_PTYPE_INNER_L4_MASK))#endif /* RTE_NEXT_ABI */ +/** Alignment constraint of mbuf private area. */ +#define RTE_MBUF_PRIV_ALIGN 8 +/** * Get the name of a RX offload flag *
@@ -1238,7 +1241,7 @@ void rte_pktmbuf_pool_init(struct rte_mempool *mp, void *opaque_arg);* details. * @param priv_size * Size of application private are between the rte_mbuf structure -* and the data buffer. +* and the data buffer. This value must be aligned to RTE_MBUF_PRIV_ALIGN. * @param data_room_size * Size of data buffer in each mbuf, including RTE_PKTMBUF_HEADROOM. * @param socket_id
@@ -1250,7 +1253,7 @@ void rte_pktmbuf_pool_init(struct rte_mempool *mp, void *opaque_arg);* with rte_errno set appropriately. Possible rte_errno values include: * - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure * - E_RTE_SECONDARY - function was called from a secondary process instance -* - EINVAL - cache size provided is too large +* - EINVAL - cache size provided is too large, or priv_size is not aligned. * - ENOSPC - the maximum number of memzones has already been allocated * - EEXIST - a memzone with the same name already exists * - ENOMEM - no appropriate memory area found in which to create memzone
Signature · 1 line
2.1.4
Re: [PATCH v2] mbuf: enforce alignment of mbuf private area
Quoted 19 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Thursday, July 30, 2015 9:22 AM
To: [email protected]
Cc: Ananyev, Konstantin; [email protected]; Zhang, Helin; [email protected]; [email protected]
Subject: [PATCH v2] mbuf: enforce alignment of mbuf private areaIt looks better to have a data buffer address that is aligned to
8 bytes. This is the case when there is no mbuf private area, but if there is one, the alignment depends on the size of this area that is located between the mbuf structure and the data buffer.Indeed, some drivers expects to have the buffer address aligned to an even address, and moreover an unaligned buffer may impact the performance when accessing to network headers.
Quoted 7 lines
Add a check in
rte_pktmbuf_pool_create()to verify the alignment constraint before creating the mempool. For applications that use the alternative way (direct call torte_mempool_create), also add an assertion inrte_pktmbuf_init().By the way, also add the MBUF log type.
Signed-off-by Olivier Matz <[email protected]>
Re: [PATCH v2] mbuf: enforce alignment of mbuf private area
In reply to Olivier MatzQuoted 23 lines
-----Original Message-----
From: Olivier Matz [mailto:[email protected]]
Sent: Thursday, July 30, 2015 5:22 PM
To: [email protected]
Cc: Ananyev, Konstantin; [email protected]; Zhang, Helin; [email protected]; [email protected]
Subject: [PATCH v2] mbuf: enforce alignment of mbuf private areaIt looks better to have a data buffer address that is aligned to 8 bytes. This is the case when there is no mbuf private area, but if there is one, the alignment depends on the size of this area that is located between the mbuf structure and the data buffer.
Indeed, some drivers expects to have the buffer address aligned to an even address, and moreover an unaligned buffer may impact the performance when accessing to network headers.
Add a check in
rte_pktmbuf_pool_create()to verify the alignment constraint before creating the mempool. For applications that use the alternative way (direct call torte_mempool_create), also add an assertion inrte_pktmbuf_init().
Quoted 4 lines
By the way, also add the MBUF log type.
Signed-off-by Olivier Matz <[email protected]>---
Thomas Monjalon
AppliedRe: [PATCH v2] mbuf: enforce alignment of mbuf private area
Quoted 14 lines
Quoted 14 lines
It looks better to have a data buffer address that is aligned to 8 bytes. This is the case when there is no mbuf private area, but if there is one, the alignment depends on the size of this area that is located between the mbuf structure and the data buffer.
Indeed, some drivers expects to have the buffer address aligned to an even address, and moreover an unaligned buffer may impact the performance when accessing to network headers.
Add a check in
rte_pktmbuf_pool_create()to verify the alignment constraint before creating the mempool. For applications that use the alternative way (direct call torte_mempool_create), also add an assertion inrte_pktmbuf_init().
Quoted 5 lines
Quoted 3 lines
By the way, also add the MBUF log type.
Signed-off-by Olivier Matz <[email protected]>
Applied, thanks
2015-07-29 18:12, Ananyev, Konstantin:
Quoted 2 lines
As we don't support split header feature anyway, I think we can fix it just by always setting HBA in the RXD to zero. Could you try the fix for ixgbe below?
Please Konstantin, could you send a proper patch for this fix? Thanks
Quoted 125 lines
drivers/net/ixgbe/ixgbe_rxtx.c +4
-4@@ -1183,7 +1183,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)/* populate the descriptors */ dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb)); - rxdp[i].read.hdr_addr = dma_addr; + rxdp[i].read.hdr_addr =0 ; rxdp[i].read.pkt_addr = dma_addr; }@@ -1414,7 +1414,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxe->mbuf = nmb; dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (nmb)); - rxdp->read.hdr_addr = dma_addr; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma_addr;/* @@ -1741,7 +1741,7 @@ next_desc: rxe->mbuf = nmb; rxm->data_off =RTE_PKTMBUF_HEADROOM ; - rxdp->read.hdr_addr = dma; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma; }else rxe->mbuf =NULL ;@@ -3633,7 +3633,7 @@ ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq) dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mbuf)); rxd = &rxq->rx_ring[i]; - rxd->read.hdr_addr = dma_addr; + rxd->read.hdr_addr =0 ; rxd->read.pkt_addr = dma_addr; rxe[i].mbuf = mbuf; }drivers/net/ixgbe/ixgbe_rxtx_vec.c +5
-0@@ -56,6 +56,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) RTE_PKTMBUF_HEADROOM);__m128i dma_addr0, dma_addr1; +const __m128i hba_msk =_mm_set_epi64x (0 ,UINT64_MAX ); + rxdp = rxq->rx_ring + rxq->rxrearm_start;/* Pull 'n' more MBUFs into the software ring */ @@ -108,6 +110,9 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) dma_addr0 =_mm_add_epi64 (dma_addr0, hdr_room); dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room); + dma_addr0 =_mm_and_si128 (dma_addr0, hba_msk); + dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk); +/* flush desc with pa dma_addr */ _mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0);_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1);bash-4.2$ cat patch1
drivers/net/ixgbe/ixgbe_rxtx.c +4
-4@@ -1183,7 +1183,7 @@ ixgbe_rx_alloc_bufs(struct ixgbe_rx_queue *rxq, bool reset_mbuf)/* populate the descriptors */ dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mb)); - rxdp[i].read.hdr_addr = dma_addr; + rxdp[i].read.hdr_addr =0 ; rxdp[i].read.pkt_addr = dma_addr; }@@ -1414,7 +1414,7 @@ ixgbe_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rxe->mbuf = nmb; dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (nmb)); - rxdp->read.hdr_addr = dma_addr; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma_addr;/* @@ -1741,7 +1741,7 @@ next_desc: rxe->mbuf = nmb; rxm->data_off =RTE_PKTMBUF_HEADROOM ; - rxdp->read.hdr_addr = dma; + rxdp->read.hdr_addr =0 ; rxdp->read.pkt_addr = dma; }else rxe->mbuf =NULL ;@@ -3633,7 +3633,7 @@ ixgbe_alloc_rx_queue_mbufs(struct ixgbe_rx_queue *rxq) dma_addr =rte_cpu_to_le_64 (RTE_MBUF_DATA_DMA_ADDR_DEFAULT (mbuf)); rxd = &rxq->rx_ring[i]; - rxd->read.hdr_addr = dma_addr; + rxd->read.hdr_addr =0 ; rxd->read.pkt_addr = dma_addr; rxe[i].mbuf = mbuf; }drivers/net/ixgbe/ixgbe_rxtx_vec.c +5
-0@@ -56,6 +56,8 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) RTE_PKTMBUF_HEADROOM);__m128i dma_addr0, dma_addr1; +const __m128i hba_msk =_mm_set_epi64x (0 ,UINT64_MAX ); + rxdp = rxq->rx_ring + rxq->rxrearm_start;/* Pull 'n' more MBUFs into the software ring */ @@ -108,6 +110,9 @@ ixgbe_rxq_rearm(struct ixgbe_rx_queue *rxq) dma_addr0 =_mm_add_epi64 (dma_addr0, hdr_room); dma_addr1 =_mm_add_epi64 (dma_addr1, hdr_room); + dma_addr0 =_mm_and_si128 (dma_addr0, hba_msk); + dma_addr1 =_mm_and_si128 (dma_addr1, hba_msk); +/* flush desc with pa dma_addr */ _mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr0);_mm_store_si128 ((__m128i *)&rxdp++->read, dma_addr1);