DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/i40e: solve vf rxq buf size alignment
@ 2021-08-23  4:11 Qiming Chen
  2021-09-06  1:49 ` Zhang, Qi Z
  0 siblings, 1 reply; 2+ messages in thread
From: Qiming Chen @ 2021-08-23  4:11 UTC (permalink / raw)
  To: dev; +Cc: beilei.xing, Qiming Chen

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.

Signed-off-by: Qiming Chen <chenqiming_huawei@163.com>
---
 drivers/net/i40e/i40e_ethdev_vf.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_ethdev_vf.c b/drivers/net/i40e/i40e_ethdev_vf.c
index 924da8dfb4..5b1c8e76ab 100644
--- a/drivers/net/i40e/i40e_ethdev_vf.c
+++ b/drivers/net/i40e/i40e_ethdev_vf.c
@@ -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);
-- 
2.30.1.windows.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] net/i40e: solve vf rxq buf size alignment
  2021-08-23  4:11 [dpdk-dev] [PATCH] net/i40e: solve vf rxq buf size alignment Qiming Chen
@ 2021-09-06  1:49 ` Zhang, Qi Z
  0 siblings, 0 replies; 2+ messages in thread
From: Zhang, Qi Z @ 2021-09-06  1:49 UTC (permalink / raw)
  To: Qiming Chen, dev; +Cc: Xing, Beilei



> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Qiming Chen
> Sent: Monday, August 23, 2021 12:11 PM
> To: dev@dpdk.org
> Cc: Xing, Beilei <beilei.xing@intel.com>; Qiming Chen
> <chenqiming_huawei@163.com>
> Subject: [dpdk-dev] [PATCH] net/i40e: solve 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.
> 
> Signed-off-by: Qiming Chen <chenqiming_huawei@163.com>
> ---
>  drivers/net/i40e/i40e_ethdev_vf.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/i40e/i40e_ethdev_vf.c
> b/drivers/net/i40e/i40e_ethdev_vf.c
> index 924da8dfb4..5b1c8e76ab 100644
> --- a/drivers/net/i40e/i40e_ethdev_vf.c
> +++ b/drivers/net/i40e/i40e_ethdev_vf.c
> @@ -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);
> --
> 2.30.1.windows.1

The patch is not applied for main repo as i40evf will be removed, you can submit a fix to dpdk-stable directly.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-06  1:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-23  4:11 [dpdk-dev] [PATCH] net/i40e: solve vf rxq buf size alignment Qiming Chen
2021-09-06  1:49 ` Zhang, Qi Z

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).