RE: [EXTERNAL] [PATCH 07/10] crypto: qat - add bank save and restore flows

Wan, Siming
2024-02-19T03:41:07Z

From: Kamlesh Gurudasani <kamlesh@ti.com>
Sent: Sunday, February 4, 2024 3:50 PM
To: Zeng, Xin <xin.zeng@intel.com>; herbert@gondor.apana.org.au; alex.williamson@redhat.com; jgg@nvidia.com; yishaih@nvidia.com; shameerali.kolothum.thodi@huawei.com; Tian, Kevin <kevin.tian@intel.com>
Cc: linux-crypto@vger.kernel.org; kvm@vger.kernel.org; qat-linux <qat-linux@intel.com>; Wan, Siming <siming.wan@intel.com>; Zeng, Xin <xin.zeng@intel.com>
Subject: Re: [EXTERNAL] [PATCH 07/10] crypto: qat - add bank save and restore flows

Xin Zeng <xin.zeng@intel.com> writes:

> This message was sent from outside of Texas Instruments.
> Do not click links or open attachments unless you recognize the source of this email and know the content is safe.
>
> From: Siming Wan <siming.wan@intel.com>
>
> Add logic to save, restore, quiesce and drain a ring bank for QAT GEN4
> devices.
> This allows to save and restore the state of a Virtual Function (VF)
> and will be used to implement VM live migration.
>
> Signed-off-by: Siming Wan <siming.wan@intel.com>
> Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
> Reviewed-by: Xin Zeng <xin.zeng@intel.com>
> Signed-off-by: Xin Zeng <xin.zeng@intel.com>
...
> +#define CHECK_STAT(op, expect_val, name, args...) \ ({ \
> + u32 __expect_val = (expect_val); \
> + u32 actual_val = op(args); \
> + if (__expect_val != actual_val) \
> + pr_err("QAT: Fail to restore %s register. Expected 0x%x, but actual is 0x%x\n", \
> + name, __expect_val, actual_val); \
> + (__expect_val == actual_val) ? 0 : -EINVAL; \
I was wondering if this can be done like following, saves repeat comparison.

(__expect_val == actual_val) ? 0 : (pr_err("QAT: Fail to restore %s \
register. Expected 0x%x, \
but actual is 0x%x\n", \
name, __expect_val, \
actual_val), -EINVAL); \ Regards, Kamlesh

> +})
...

Thanks for your comments! Will update.