net/i40e: fix vf rxq buf size alignment
PATCH 1/1 net/i40e: fix vf rxq buf size alignment
The RTE_ALIGN macro is aligned upwards. If the buf_size variable is not aligned with 1 << I40E_RXQ_CTX_DBUFF_SHIFT, the rx_buf_len is larger than the actual mbuf memory after the operation. When receiving the packet, if the packet is larger than the configured buf_size, it will cause a memory stepping event.
The patch uses the RTE_ALIGN_FLOOR down alignment macro to correct the problem.
--- drivers/net/i40e/i40e_ethdev_vf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/i40e/i40e_ethdev_vf.c +1 -1
@@ -1927,7 +1927,7 @@ i40evf_rxq_init(struct rte_eth_dev *dev, struct i40e_rx_queue *rxq) RTE_PKTMBUF_HEADROOM); rxq->hs_mode = i40e_header_split_none; rxq->rx_hdr_len =0 ; - rxq->rx_buf_len =RTE_ALIGN (buf_size, (1 <<I40E_RXQ_CTX_DBUFF_SHIFT )); + rxq->rx_buf_len =RTE_ALIGN_FLOOR (buf_size, (1 <<I40E_RXQ_CTX_DBUFF_SHIFT )); len = rxq->rx_buf_len *I40E_MAX_CHAINED_RX_BUFFERS ; rxq->max_pkt_len =RTE_MIN (len, dev_data->dev_conf.rxmode.max_rx_pkt_len);
Signature · 1 line
2.30.1.windows.1
Quoted 22 lines · Qiming Chen
The
RTE_ALIGNmacro is aligned upwards. If thebuf_sizevariable is not aligned with 1 <<I40E_RXQ_CTX_DBUFF_SHIFT, therx_buf_lenis larger than the actual mbuf memory after the operation. When receiving the packet, if the packet is larger than the configuredbuf_size, it will cause a memory stepping event.The patch uses the
RTE_ALIGN_FLOORdown alignment macro to correct the problem.Fixes c1715402df8f ("i40evf: fix jumbo frame support")Signed-off-by Qiming Chen <[email protected]>--- drivers/net/i40e/i40e_ethdev_vf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/i40e/i40e_ethdev_vf.c +0
-0
drivers/net/i40e/i40e_ethdev_vf.c i40evf_rxq_init(struct rte_eth_dev *dev, struct i40e_rx_queue *rxq) · line 1933
Quoted 8 lines
drivers/net/i40e/i40e_ethdev_vf.c +1
-1@@ -1927,7 +1927,7 @@ i40evf_rxq_init(struct rte_eth_dev *dev, struct i40e_rx_queue *rxq) RTE_PKTMBUF_HEADROOM); rxq->hs_mode = i40e_header_split_none; rxq->rx_hdr_len =0 ; - rxq->rx_buf_len =RTE_ALIGN (buf_size, (1 <<I40E_RXQ_CTX_DBUFF_SHIFT )); + rxq->rx_buf_len =RTE_ALIGN_FLOOR (buf_size, (1 <<I40E_RXQ_CTX_DBUFF_SHIFT )); len = rxq->rx_buf_len *I40E_MAX_CHAINED_RX_BUFFERS ; rxq->max_pkt_len =RTE_MIN (len, dev_data->dev_conf.rxmode.max_rx_pkt_len);
Added to 20.11.4 pipeline, thanks!