From: David Christensen <drc@linux.vnet.ibm.com>
To: shannon.nelson@amd.com, brett.creeley@amd.com, drivers@pensando.io
Cc: netdev@vger.kernel.org, David Christensen <drc@linux.vnet.ibm.com>
Subject: [PATCH] ionic: fix 16bit math issue when PAGE_SIZE >= 64KB
Date: Mon, 11 Sep 2023 18:22:12 -0400 [thread overview]
Message-ID: <20230911222212.103406-1-drc@linux.vnet.ibm.com> (raw)
The function ionic_rx_fill() uses 16bit math when calculating the
the number of pages required for an RX descriptor given an interface
MTU setting. If the system PAGE_SIZE >= 64KB, the frag_len and
remain_len values will always be 0, causing unnecessary scatter-
gather elements to be assigned to the RX descriptor, up to the
maximum number of scatter-gather elements per descriptor.
A similar change in ionic_rx_frags() is implemented for symmetry,
but has not been observed as an issue since scatter-gather
elements are not necessary for such larger page sizes.
Fixes: 4b0a7539a372 ("ionic: implement Rx page reuse")
Signed-off-by: David Christensen <drc@linux.vnet.ibm.com>
---
drivers/net/ethernet/pensando/ionic/ionic_txrx.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
index 26798fc635db..56502bc80e01 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
@@ -182,8 +182,8 @@ static struct sk_buff *ionic_rx_frags(struct ionic_queue *q,
struct device *dev = q->dev;
struct sk_buff *skb;
unsigned int i;
- u16 frag_len;
- u16 len;
+ u32 frag_len;
+ u32 len;
stats = q_to_rx_stats(q);
@@ -207,7 +207,7 @@ static struct sk_buff *ionic_rx_frags(struct ionic_queue *q,
return NULL;
}
- frag_len = min_t(u16, len, IONIC_PAGE_SIZE - buf_info->page_offset);
+ frag_len = min_t(u32, len, IONIC_PAGE_SIZE - buf_info->page_offset);
len -= frag_len;
dma_sync_single_for_cpu(dev,
@@ -452,7 +452,7 @@ void ionic_rx_fill(struct ionic_queue *q)
/* fill main descriptor - buf[0] */
desc->addr = cpu_to_le64(buf_info->dma_addr + buf_info->page_offset);
- frag_len = min_t(u16, len, IONIC_PAGE_SIZE - buf_info->page_offset);
+ frag_len = min_t(u32, len, IONIC_PAGE_SIZE - buf_info->page_offset);
desc->len = cpu_to_le16(frag_len);
remain_len -= frag_len;
buf_info++;
@@ -471,7 +471,7 @@ void ionic_rx_fill(struct ionic_queue *q)
}
sg_elem->addr = cpu_to_le64(buf_info->dma_addr + buf_info->page_offset);
- frag_len = min_t(u16, remain_len, IONIC_PAGE_SIZE - buf_info->page_offset);
+ frag_len = min_t(u32, remain_len, IONIC_PAGE_SIZE - buf_info->page_offset);
sg_elem->len = cpu_to_le16(frag_len);
remain_len -= frag_len;
buf_info++;
--
2.39.1
next reply other threads:[~2023-09-11 22:24 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-11 22:22 David Christensen [this message]
2023-09-12 0:14 ` [PATCH] ionic: fix 16bit math issue when PAGE_SIZE >= 64KB Jacob Keller
2023-09-12 20:48 ` David Christensen
2023-09-12 21:13 ` Jacob Keller
2023-09-12 0:24 ` Nelson, Shannon
2023-09-12 22:31 ` David Christensen
2023-09-14 20:28 ` Nelson, Shannon
2023-09-14 20:39 ` Nelson, Shannon
2023-09-14 22:02 ` [PATCH net v2] " David Christensen
2023-09-15 16:55 ` Nelson, Shannon
2023-09-16 10:50 ` patchwork-bot+netdevbpf
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=20230911222212.103406-1-drc@linux.vnet.ibm.com \
--to=drc@linux.vnet.ibm.com \
--cc=brett.creeley@amd.com \
--cc=drivers@pensando.io \
--cc=netdev@vger.kernel.org \
--cc=shannon.nelson@amd.com \
/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).