From: edwin.brossette@6wind.com
To: dev@dpdk.org
Cc: olivier.matz@6wind.com, didier.pallard@6wind.com,
lauren.hardy@6wind.com, dsinghrawat@marvell.com,
palok@marvell.com, Edwin Brossette <edwin.brossette@6wind.com>,
stable@dpdk.org
Subject: [PATCH 4/5] net/qede: fix QEDE_ETH_OVERHEAD being counted twice in rx_buf_size
Date: Tue, 22 Apr 2025 17:51:42 +0200 [thread overview]
Message-ID: <20250422155143.3893525-4-edwin.brossette@6wind.com> (raw)
In-Reply-To: <20250422155143.3893525-1-edwin.brossette@6wind.com>
From: Edwin Brossette <edwin.brossette@6wind.com>
rx_buf_size is computed at 2 different places: in qede_rx_queue_setup()
and in qede_set_mtu().
In qede_rx_queue_setup(), it is initialized with mtu + RTE_ETHER_HDR_LEN
and QEDE_ETH_OVERHEAD is added to it in qede_calc_rx_buf_size().
In qede_set_mtu(), it is initialized with
mtu + RTE_ETHER_HDR_LEN + QEDE_ETH_OVERHEAD and QEDE_ETH_OVERHEAD is
added to it a second time in qede_calc_rx_buf_size().
This is inconsistent and wrong in the case of qede_set_mtu(). Initialize
this variable with mtu + QEDE_MAX_ETHER_HDR_LEN instead and stop adding
+ QEDE_ETH_OVERHEAD over and over again. This will factorize the code.
Fixes: 318d7da3122b ("net/qede: fix Rx buffer size calculation")
CC: stable@dpdk.org
Signed-off-by: Edwin Brossette <edwin.brossette@6wind.com>
Acked-by: Didier Pallard <didier.pallard@6wind.com>
---
drivers/net/qede/qede_rxtx.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/drivers/net/qede/qede_rxtx.c b/drivers/net/qede/qede_rxtx.c
index fe839a6ba844..ea77f09e18be 100644
--- a/drivers/net/qede/qede_rxtx.c
+++ b/drivers/net/qede/qede_rxtx.c
@@ -101,19 +101,14 @@ qede_calc_rx_buf_size(struct rte_eth_dev *dev, uint16_t mbufsz,
* buffers can be used for single packet. So need to make sure
* mbuf size is sufficient enough for this.
*/
- if ((mbufsz * ETH_RX_MAX_BUFF_PER_PKT) <
- (max_frame_size + QEDE_ETH_OVERHEAD)) {
+ if ((mbufsz * ETH_RX_MAX_BUFF_PER_PKT) < max_frame_size) {
DP_ERR(edev, "mbuf %d size is not enough to hold max fragments (%d) for max rx packet length (%d)\n",
mbufsz, ETH_RX_MAX_BUFF_PER_PKT, max_frame_size);
return -EINVAL;
}
-
- rx_buf_size = RTE_MAX(mbufsz,
- (max_frame_size + QEDE_ETH_OVERHEAD) /
- ETH_RX_MAX_BUFF_PER_PKT);
- } else {
- rx_buf_size = max_frame_size + QEDE_ETH_OVERHEAD;
- }
+ rx_buf_size = mbufsz;
+ } else
+ rx_buf_size = max_frame_size;
/* Align to cache-line size if needed */
return QEDE_FLOOR_TO_CACHE_LINE_SIZE(rx_buf_size);
@@ -235,14 +230,14 @@ qede_rx_queue_setup(struct rte_eth_dev *dev, uint16_t qid,
dev->data->rx_queues[qid] = NULL;
}
- max_rx_pktlen = dev->data->mtu + RTE_ETHER_HDR_LEN;
+ max_rx_pktlen = dev->data->mtu + QEDE_MAX_ETHER_HDR_LEN;
/* Fix up RX buffer size */
bufsz = (uint16_t)rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADROOM;
/* cache align the mbuf size to simplify rx_buf_size calculation */
bufsz = QEDE_FLOOR_TO_CACHE_LINE_SIZE(bufsz);
if ((rxmode->offloads & RTE_ETH_RX_OFFLOAD_SCATTER) ||
- (max_rx_pktlen + QEDE_ETH_OVERHEAD) > bufsz) {
+ max_rx_pktlen > bufsz) {
if (!dev->data->scattered_rx) {
DP_INFO(edev, "Forcing scatter-gather mode\n");
dev->data->scattered_rx = 1;
--
2.35.0.4.g44a5d4affccf
next prev parent reply other threads:[~2025-04-22 15:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-22 15:39 QEDE bug report Edwin Brossette
2025-04-22 15:51 ` [PATCH 1/5] qede: fix tunnel checksums offload flags edwin.brossette
2025-04-22 15:51 ` [PATCH 2/5] net/qede: fix bad sanity check on Rx queue release edwin.brossette
2025-04-23 15:30 ` Stephen Hemminger
2025-04-22 15:51 ` [PATCH 3/5] Revert "net/qede: fix maximum Rx packet length" edwin.brossette
2025-04-22 15:51 ` edwin.brossette [this message]
2025-04-22 15:51 ` [PATCH 5/5] net/qede: fix rx_buf_size calculation edwin.brossette
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250422155143.3893525-4-edwin.brossette@6wind.com \
--to=edwin.brossette@6wind.com \
--cc=dev@dpdk.org \
--cc=didier.pallard@6wind.com \
--cc=dsinghrawat@marvell.com \
--cc=lauren.hardy@6wind.com \
--cc=olivier.matz@6wind.com \
--cc=palok@marvell.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).