From cd8e2d82922ad3596e410f8ff1063802754a3180 Mon Sep 17 00:00:00 2001 From: Ivan Malov Date: Fri, 12 Aug 2022 15:24:54 +0300 Subject: [PATCH] net/sfc: clarify Rx buffer size calculation The user has the right to supply pools with excessively large buffers, regardless of the maximum supported Rx packet length reported by the adapter. However, in this PMD, on EF10 boards, a Rx descriptor has only 14 bits to specify the buffer length. To avoid potential problems, use this information accordingly. Signed-off-by: Ivan Malov Reviewed-by: Andrew Rybchenko --- drivers/net/sfc/sfc_rx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/sfc/sfc_rx.c b/drivers/net/sfc/sfc_rx.c index 128aa9753a..5ea98187c3 100644 --- a/drivers/net/sfc/sfc_rx.c +++ b/drivers/net/sfc/sfc_rx.c @@ -1081,7 +1081,11 @@ sfc_rx_mb_pool_buf_size(struct sfc_adapter *sa, struct rte_mempool *mb_pool) buf_size = EFX_P2ALIGN(uint32_t, buf_size, nic_align_end); } - return buf_size; + /* + * Buffer length field of a Rx descriptor may not be wide + * enough to store a 16-bit data count taken from an mbuf. + */ + return MIN(buf_size, encp->enc_rx_dma_desc_size_max); } int