From: Haiyue Wang <haiyue.wang@cloudprime.ai>
To: io-uring@vger.kernel.org
Cc: Haiyue Wang <haiyue.wang@cloudprime.ai>
Subject: [PATCH liburing v1 6/6] test/zcrx: use uring_ptr_to_u64() helper to convert ptr to u64
Date: Wed, 18 Jun 2025 15:49:21 +0800 [thread overview]
Message-ID: <6678AFF9D9CC2DEE+20250618075056.142118-7-haiyue.wang@cloudprime.ai> (raw)
In-Reply-To: <20250618075056.142118-1-haiyue.wang@cloudprime.ai>
Use the helper to handle type convertions, instead of two type
convertions by hand: '(__u64) (unsigned long)'.
Signed-off-by: Haiyue Wang <haiyue.wang@cloudprime.ai>
---
test/zcrx.c | 44 ++++++++++++++++++++++----------------------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/test/zcrx.c b/test/zcrx.c
index 61c984d..572e118 100644
--- a/test/zcrx.c
+++ b/test/zcrx.c
@@ -43,7 +43,7 @@ static char str[] = "iv5t4dl500w7wsrf14fsuq8thptto0z7i2q62z1p8dwrv5u4kaxpqhm2rb7
static int probe_zcrx(void *area)
{
struct io_uring_zcrx_area_reg area_reg = {
- .addr = (__u64)(unsigned long)area,
+ .addr = uring_ptr_to_u64(area),
.len = AREA_SZ,
.flags = 0,
};
@@ -51,7 +51,7 @@ static int probe_zcrx(void *area)
.if_idx = ifidx,
.if_rxq = rxq,
.rq_entries = RQ_ENTRIES,
- .area_ptr = (__u64)(unsigned long)&area_reg,
+ .area_ptr = uring_ptr_to_u64(&area_reg),
};
struct io_uring ring;
int ret;
@@ -99,7 +99,7 @@ static int test_invalid_if(void *area)
{
int ret;
struct io_uring_zcrx_area_reg area_reg = {
- .addr = (__u64)(unsigned long)area,
+ .addr = uring_ptr_to_u64(area),
.len = AREA_SZ,
.flags = 0,
};
@@ -107,7 +107,7 @@ static int test_invalid_if(void *area)
.if_idx = -1,
.if_rxq = rxq,
.rq_entries = RQ_ENTRIES,
- .area_ptr = (__u64)(unsigned long)&area_reg,
+ .area_ptr = uring_ptr_to_u64(&area_reg),
};
ret = try_register_ifq(®);
@@ -131,7 +131,7 @@ static int test_invalid_ifq_collision(void *area)
{
struct io_uring ring, ring2;
struct io_uring_zcrx_area_reg area_reg = {
- .addr = (__u64)(unsigned long)area,
+ .addr = uring_ptr_to_u64(area),
.len = AREA_SZ,
.flags = 0,
};
@@ -139,7 +139,7 @@ static int test_invalid_ifq_collision(void *area)
.if_idx = ifidx,
.if_rxq = rxq,
.rq_entries = RQ_ENTRIES,
- .area_ptr = (__u64)(unsigned long)&area_reg,
+ .area_ptr = uring_ptr_to_u64(&area_reg),
};
int ret;
@@ -182,7 +182,7 @@ static int test_rq_setup(void *area)
{
int ret;
struct io_uring_zcrx_area_reg area_reg = {
- .addr = (__u64)(unsigned long)area,
+ .addr = uring_ptr_to_u64(area),
.len = AREA_SZ,
.flags = 0,
};
@@ -191,7 +191,7 @@ static int test_rq_setup(void *area)
.if_idx = ifidx,
.if_rxq = rxq,
.rq_entries = 0,
- .area_ptr = (__u64)(unsigned long)&area_reg,
+ .area_ptr = uring_ptr_to_u64(&area_reg),
};
ret = try_register_ifq(®);
@@ -232,7 +232,7 @@ static int test_null_area_reg_struct(void)
.if_idx = ifidx,
.if_rxq = rxq,
.rq_entries = RQ_ENTRIES,
- .area_ptr = (__u64)(unsigned long)0,
+ .area_ptr = uring_ptr_to_u64(0),
};
ret = try_register_ifq(®);
@@ -244,7 +244,7 @@ static int test_null_area(void)
int ret;
struct io_uring_zcrx_area_reg area_reg = {
- .addr = (__u64)(unsigned long)0,
+ .addr = uring_ptr_to_u64(0),
.len = AREA_SZ,
.flags = 0,
};
@@ -253,7 +253,7 @@ static int test_null_area(void)
.if_idx = ifidx,
.if_rxq = rxq,
.rq_entries = RQ_ENTRIES,
- .area_ptr = (__u64)(unsigned long)&area_reg,
+ .area_ptr = uring_ptr_to_u64(&area_reg),
};
ret = try_register_ifq(®);
@@ -264,7 +264,7 @@ static int test_misaligned_area(void *area)
{
int ret;
struct io_uring_zcrx_area_reg area_reg = {
- .addr = (__u64)(unsigned long)(area + 1),
+ .addr = uring_ptr_to_u64(area + 1),
.len = AREA_SZ,
.flags = 0,
};
@@ -273,13 +273,13 @@ static int test_misaligned_area(void *area)
.if_idx = ifidx,
.if_rxq = rxq,
.rq_entries = RQ_ENTRIES,
- .area_ptr = (__u64)(unsigned long)&area_reg,
+ .area_ptr = uring_ptr_to_u64(&area_reg),
};
if (!try_register_ifq(®))
return T_EXIT_FAIL;
- area_reg.addr = (__u64)(unsigned long)area;
+ area_reg.addr = uring_ptr_to_u64(area);
area_reg.len = AREA_SZ - 1;
ret = try_register_ifq(®);
return ret ? T_EXIT_PASS : T_EXIT_FAIL;
@@ -289,7 +289,7 @@ static int test_larger_than_alloc_area(void *area)
{
int ret;
struct io_uring_zcrx_area_reg area_reg = {
- .addr = (__u64)(unsigned long)area,
+ .addr = uring_ptr_to_u64(area),
.len = AREA_SZ + 4096,
.flags = 0,
};
@@ -298,7 +298,7 @@ static int test_larger_than_alloc_area(void *area)
.if_idx = ifidx,
.if_rxq = rxq,
.rq_entries = RQ_ENTRIES,
- .area_ptr = (__u64)(unsigned long)&area_reg,
+ .area_ptr = uring_ptr_to_u64(&area_reg),
};
ret = try_register_ifq(®);
@@ -315,7 +315,7 @@ static int test_area_access(void)
.if_idx = ifidx,
.if_rxq = rxq,
.rq_entries = RQ_ENTRIES,
- .area_ptr = (__u64)(unsigned long)&area_reg,
+ .area_ptr = uring_ptr_to_u64(&area_reg),
};
int i, ret;
void *area;
@@ -331,7 +331,7 @@ static int test_area_access(void)
return T_EXIT_FAIL;
}
- area_reg.addr = (__u64)(unsigned long)area;
+ area_reg.addr = uring_ptr_to_u64(area);
ret = try_register_ifq(®);
if (ret != -EFAULT) {
@@ -348,7 +348,7 @@ static int test_area_access(void)
static int create_ring_with_ifq(struct io_uring *ring, void *area, __u32 *id)
{
struct io_uring_zcrx_area_reg area_reg = {
- .addr = (__u64)(unsigned long)area,
+ .addr = uring_ptr_to_u64(area),
.len = AREA_SZ,
.flags = 0,
};
@@ -356,7 +356,7 @@ static int create_ring_with_ifq(struct io_uring *ring, void *area, __u32 *id)
.if_idx = ifidx,
.if_rxq = rxq,
.rq_entries = RQ_ENTRIES,
- .area_ptr = (__u64)(unsigned long)&area_reg,
+ .area_ptr = uring_ptr_to_u64(&area_reg),
};
int ret;
@@ -653,7 +653,7 @@ static void *recv_fn(void *data)
struct io_uring ring;
int ret, sock;
struct io_uring_zcrx_area_reg area_reg = {
- .addr = (__u64)(unsigned long)rd->area,
+ .addr = uring_ptr_to_u64(rd->area),
.len = AREA_SZ,
.flags = 0,
};
@@ -661,7 +661,7 @@ static void *recv_fn(void *data)
.if_idx = ifidx,
.if_rxq = rxq,
.rq_entries = RQ_ENTRIES,
- .area_ptr = (__u64)(unsigned long)&area_reg,
+ .area_ptr = uring_ptr_to_u64(&area_reg),
};
p.flags = RING_FLAGS;
--
2.49.0
prev parent reply other threads:[~2025-06-18 7:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250618075056.142118-1-haiyue.wang@cloudprime.ai>
2025-06-18 7:49 ` [PATCH liburing v1 1/6] Add uring_ptr_to_u64() helper Haiyue Wang
2025-06-18 7:49 ` [PATCH liburing v1 2/6] liburing: use uring_ptr_to_u64() helper to convert ptr to u64 Haiyue Wang
2025-06-18 7:49 ` [PATCH liburing v1 3/6] examples/reg-wait: " Haiyue Wang
2025-06-18 7:49 ` [PATCH liburing v1 4/6] examples/zcrx: " Haiyue Wang
2025-06-18 7:49 ` [PATCH liburing v1 5/6] test/reg-wait: " Haiyue Wang
2025-06-18 7:49 ` Haiyue Wang [this message]
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=6678AFF9D9CC2DEE+20250618075056.142118-7-haiyue.wang@cloudprime.ai \
--to=haiyue.wang@cloudprime.ai \
--cc=io-uring@vger.kernel.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