From: Andre Muezerie <andremue@linux.microsoft.com>
To: Dariusz Sosnowski <dsosnowski@nvidia.com>
Cc: Viacheslav Ovsiienko <viacheslavo@nvidia.com>,
Bing Zhao <bingz@nvidia.com>, Ori Kam <orika@nvidia.com>,
Suanming Mou <suanmingm@nvidia.com>,
Matan Azrad <matan@nvidia.com>,
dev@dpdk.org
Subject: Re: [PATCH] common/mlx5: use intrinsics instead of inline assembly
Date: Wed, 4 Jun 2025 07:17:46 -0700 [thread overview]
Message-ID: <20250604141746.GA9366@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> (raw)
In-Reply-To: <20250603151253.jjctszshwamnepdy@ds-vm-debian.local>
On Tue, Jun 03, 2025 at 05:13:14PM +0200, Dariusz Sosnowski wrote:
> Hi,
>
> On Mon, May 05, 2025 at 07:57:42AM -0700, Andre Muezerie wrote:
> > When compiling with MSVC the errors below are hit because msvc does not
> > support inline assembly:
> >
> > 1)
> > ../drivers/common/mlx5/mlx5_common.c(86): warning C4013: '__asm__'
> > undefined; assuming extern returning int
> > ../drivers/common/mlx5/mlx5_common.c(87): error C2143: syntax error:
> > missing ')' before ':'
> >
> > 2)
> > ../drivers/net/mlx5/mlx5_txpp.c(510): error C2065: '__asm__':
> > undeclared identifier
> > ../drivers/net/mlx5/mlx5_txpp.c(510): error C2143: syntax error:
> > missing ';' before 'volatile'
> >
> > The fix for (1) is to use compiler intrinsic __cpuid and for (2)
> > intrinsic _InterlockedCompareExchange128 can be used.
> >
> > Signed-off-by: Andre Muezerie <andremue@linux.microsoft.com>
>
> *snip*
>
> > diff --git a/drivers/net/mlx5/mlx5_txpp.c b/drivers/net/mlx5/mlx5_txpp.c
> > index e6d3ad83e9..5bbaf668e6 100644
> > --- a/drivers/net/mlx5/mlx5_txpp.c
> > +++ b/drivers/net/mlx5/mlx5_txpp.c
> > @@ -486,6 +486,20 @@ mlx5_txpp_cq_arm(struct mlx5_dev_ctx_shared *sh)
> > }
> >
> > #if defined(RTE_ARCH_X86_64)
> > +#ifdef RTE_TOOLCHAIN_MSVC
> > +static inline int
> > +mlx5_atomic128_compare_exchange(rte_int128_t *dst,
> > + rte_int128_t *exp,
> > + const rte_int128_t *src)
> > +{
> > + return (int)_InterlockedCompareExchange128(
> > + (int64_t volatile *)dst,
> > + src->val[1], /* exchange high */
> > + src->val[0], /* exchange low */
> > + (int64_t *)exp /* comparand result */
> > + );
>
> There is one checkpatch warning to fix here:
>
> CHECK:OPEN_ENDED_LINE: Lines should not end with a '('
> #117: FILE: drivers/net/mlx5/mlx5_txpp.c:495:
> + return (int)_InterlockedCompareExchange128(
>
> Also, I don't think that comments for arguments are needed here.
>
> Could you please organize the code as follows:
>
> return (int)_InterlockedCompareExchange128((int64_t volatile *)dst,
> src->val[1], src->val[0], (int64_t *)exp);
>
Sure. I sent out a v2 of this patch with the suggested change.
> > +}
> > +#else
> > static inline int
> > mlx5_atomic128_compare_exchange(rte_int128_t *dst,
> > rte_int128_t *exp,
> > @@ -510,6 +524,7 @@ mlx5_atomic128_compare_exchange(rte_int128_t *dst,
> > return res;
> > }
> > #endif
> > +#endif
> >
> > static inline void
> > mlx5_atomic_read_cqe(rte_int128_t *from, rte_int128_t *ts)
>
> Best regards,
> Dariusz Sosnowski
next prev parent reply other threads:[~2025-06-04 14:17 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-05 14:57 Andre Muezerie
2025-06-03 1:07 ` Andre Muezerie
2025-06-03 15:13 ` Dariusz Sosnowski
2025-06-04 14:17 ` Andre Muezerie [this message]
2025-06-04 14:15 ` [PATCH v2] " Andre Muezerie
2025-06-05 8:33 ` Dariusz Sosnowski
2025-06-05 8:35 ` Dariusz Sosnowski
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=20250604141746.GA9366@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net \
--to=andremue@linux.microsoft.com \
--cc=bingz@nvidia.com \
--cc=dev@dpdk.org \
--cc=dsosnowski@nvidia.com \
--cc=matan@nvidia.com \
--cc=orika@nvidia.com \
--cc=suanmingm@nvidia.com \
--cc=viacheslavo@nvidia.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).