From: longli@linuxonhyperv.com
To: Stephen Hemminger <stephen@networkplumber.org>,
Wei Hu <weh@microsoft.com>
Cc: dev@dpdk.org, Long Li <longli@microsoft.com>, stable@dpdk.org
Subject: [PATCH 4/4] net/netvsc: Use Hyper-V page size for the driver
Date: Fri, 18 Apr 2025 12:32:50 -0700 [thread overview]
Message-ID: <1745004770-9795-5-git-send-email-longli@linuxonhyperv.com> (raw)
In-Reply-To: <1745004770-9795-1-git-send-email-longli@linuxonhyperv.com>
From: Long Li <longli@microsoft.com>
The driver should always use Hyper-V page size for implementing RNDIS and
calculating PFN (Page Frame Number) for communicating with Hyper-V VSP.
It should not use system page size as it may be different to the Hyper-V
page size.
Fixes: 4e9c73e96e ("net/netvsc: add Hyper-V network device")
Cc: stable@dpdk.org
Signed-off-by: Long Li <longli@microsoft.com>
---
drivers/net/netvsc/hn_rndis.c | 14 +++++++-------
drivers/net/netvsc/hn_rxtx.c | 16 ++++++++--------
drivers/net/netvsc/hn_var.h | 4 ----
3 files changed, 15 insertions(+), 19 deletions(-)
diff --git a/drivers/net/netvsc/hn_rndis.c b/drivers/net/netvsc/hn_rndis.c
index 12bea33e37..7c54eebcef 100644
--- a/drivers/net/netvsc/hn_rndis.c
+++ b/drivers/net/netvsc/hn_rndis.c
@@ -67,7 +67,7 @@ hn_rndis_rid(struct hn_data *hv)
static void *hn_rndis_alloc(size_t size)
{
- return rte_zmalloc("RNDIS", size, rte_mem_page_size());
+ return rte_zmalloc("RNDIS", size, HYPERV_PAGE_SIZE);
}
#ifdef RTE_LIBRTE_NETVSC_DEBUG_DUMP
@@ -266,17 +266,17 @@ static int hn_nvs_send_rndis_ctrl(struct hn_data *hv,
return -EINVAL;
}
- if (unlikely(reqlen > rte_mem_page_size())) {
+ if (unlikely(reqlen > HYPERV_PAGE_SIZE)) {
PMD_DRV_LOG(ERR, "RNDIS request %u greater than page size",
reqlen);
return -EINVAL;
}
- sg.page = addr / rte_mem_page_size();
- sg.ofs = addr & PAGE_MASK;
+ sg.page = addr / HYPERV_PAGE_SIZE;
+ sg.ofs = addr & HYPERV_PAGE_MASK;
sg.len = reqlen;
- if (sg.ofs + reqlen > rte_mem_page_size()) {
+ if (sg.ofs + reqlen > HYPERV_PAGE_SIZE) {
PMD_DRV_LOG(ERR, "RNDIS request crosses page boundary");
return -EINVAL;
}
@@ -481,7 +481,7 @@ hn_rndis_query(struct hn_data *hv, uint32_t oid,
return -ENOMEM;
comp_len = sizeof(*comp) + odlen;
- comp = rte_zmalloc("QUERY", comp_len, rte_mem_page_size());
+ comp = rte_zmalloc("QUERY", comp_len, HYPERV_PAGE_SIZE);
if (!comp) {
error = -ENOMEM;
goto done;
@@ -738,7 +738,7 @@ hn_rndis_set(struct hn_data *hv, uint32_t oid, const void *data, uint32_t dlen)
int error;
reqlen = sizeof(*req) + dlen;
- req = rte_zmalloc("RNDIS_SET", reqlen, rte_mem_page_size());
+ req = rte_zmalloc("RNDIS_SET", reqlen, HYPERV_PAGE_SIZE);
if (!req)
return -ENOMEM;
diff --git a/drivers/net/netvsc/hn_rxtx.c b/drivers/net/netvsc/hn_rxtx.c
index ffa6937ce2..44faf22da7 100644
--- a/drivers/net/netvsc/hn_rxtx.c
+++ b/drivers/net/netvsc/hn_rxtx.c
@@ -1432,10 +1432,10 @@ static unsigned int hn_get_slots(const struct rte_mbuf *m)
while (m) {
unsigned int size = rte_pktmbuf_data_len(m);
- unsigned int offs = rte_mbuf_data_iova(m) & PAGE_MASK;
+ unsigned int offs = rte_mbuf_data_iova(m) & HYPERV_PAGE_MASK;
- slots += (offs + size + rte_mem_page_size() - 1) /
- rte_mem_page_size();
+ slots += (offs + size + HYPERV_PAGE_SIZE - 1) /
+ HYPERV_PAGE_SIZE;
m = m->next;
}
@@ -1450,13 +1450,13 @@ static unsigned int hn_fill_sg(struct vmbus_gpa *sg,
while (m) {
rte_iova_t addr = rte_mbuf_data_iova(m);
- unsigned int page = addr / rte_mem_page_size();
- unsigned int offset = addr & PAGE_MASK;
+ unsigned int page = addr / HYPERV_PAGE_SIZE;
+ unsigned int offset = addr & HYPERV_PAGE_MASK;
unsigned int len = rte_pktmbuf_data_len(m);
while (len > 0) {
unsigned int bytes = RTE_MIN(len,
- rte_mem_page_size() - offset);
+ HYPERV_PAGE_SIZE - offset);
sg[segs].page = page;
sg[segs].ofs = offset;
@@ -1499,8 +1499,8 @@ static int hn_xmit_sg(struct hn_tx_queue *txq,
addr = txq->tx_rndis_iova +
((char *)txd->rndis_pkt - (char *)txq->tx_rndis);
- sg[0].page = addr / rte_mem_page_size();
- sg[0].ofs = addr & PAGE_MASK;
+ sg[0].page = addr / HYPERV_PAGE_SIZE;
+ sg[0].ofs = addr & HYPERV_PAGE_MASK;
sg[0].len = RNDIS_PACKET_MSG_OFFSET_ABS(hn_rndis_pktlen(txd->rndis_pkt));
segs = 1;
diff --git a/drivers/net/netvsc/hn_var.h b/drivers/net/netvsc/hn_var.h
index 0f638bc5fd..f946b3d8ef 100644
--- a/drivers/net/netvsc/hn_var.h
+++ b/drivers/net/netvsc/hn_var.h
@@ -31,10 +31,6 @@
#define HN_RX_EXTMBUF_ENABLE 0
-#ifndef PAGE_MASK
-#define PAGE_MASK (rte_mem_page_size() - 1)
-#endif
-
struct hn_data;
struct hn_txdesc;
--
2.34.1
next prev parent reply other threads:[~2025-04-18 19:33 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-18 19:32 [PATCH 0/4] Fix incorrect page size and address caclulations on systems with 64k (or other) page sizes longli
2025-04-18 19:32 ` [PATCH 1/4] bus/vmbus: Align ring buffer data region to system page boundary longli
2025-04-18 19:32 ` [PATCH 2/4] bus/vmbus: Define Hyper-V page size longli
2025-04-18 19:32 ` [PATCH 3/4] bus/vmbus: Use Hyper-V page size for mapping to UIO pages longli
2025-04-18 19:32 ` longli [this message]
2025-04-21 15:33 ` [EXTERNAL] [PATCH 0/4] Fix incorrect page size and address caclulations on systems with 64k (or other) page sizes Wei Hu
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=1745004770-9795-5-git-send-email-longli@linuxonhyperv.com \
--to=longli@linuxonhyperv.com \
--cc=dev@dpdk.org \
--cc=longli@microsoft.com \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
--cc=weh@microsoft.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.