From: "Piotr Piórkowski" <piotr.piorkowski@intel.com>
To: Michal Wajdeczko <michal.wajdeczko@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
Lucas De Marchi <lucas.demarchi@intel.com>
Subject: Re: [PATCH 12/12] drm/xe/tests: Add KUnit tests for VF control GuC messages
Date: Fri, 23 Aug 2024 15:18:05 +0200 [thread overview]
Message-ID: <20240823131805.sf5rf2k3onbvez3p@intel.com> (raw)
In-Reply-To: <20240809165159.662-13-michal.wajdeczko@intel.com>
Michal Wajdeczko <michal.wajdeczko@intel.com> wrote on pią [2024-sie-09 18:51:59 +0200]:
> Add KUnit tests (~50) to cover all possible VF control messages
> that could be seen by the PF, either expected or corrupted.
>
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Cc: Lucas De Marchi <lucas.demarchi@intel.com>
> ---
> .../xe/tests/xe_gt_sriov_pf_control_kunit.c | 194 ++++++++++++++++++
> 1 file changed, 194 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_control_kunit.c b/drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_control_kunit.c
> index 4252577b4bbd..194fcf5687d1 100644
> --- a/drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_control_kunit.c
> +++ b/drivers/gpu/drm/xe/tests/xe_gt_sriov_pf_control_kunit.c
> @@ -1358,3 +1358,197 @@ static struct kunit_suite pf_control_suite = {
> };
>
> kunit_test_suite(pf_control_suite);
> +
> +#define PREP_MSG_0_VF_STATE_NOTIFY(mbz) \
> + FIELD_PREP_CONST(GUC_HXG_MSG_0_ORIGIN, GUC_HXG_ORIGIN_GUC) | \
> + FIELD_PREP_CONST(GUC_HXG_MSG_0_TYPE, GUC_HXG_TYPE_EVENT) | \
> + FIELD_PREP_CONST(GUC_HXG_EVENT_MSG_0_DATA0, (mbz)) | \
> + FIELD_PREP_CONST(GUC_HXG_EVENT_MSG_0_ACTION, GUC_ACTION_GUC2PF_VF_STATE_NOTIFY)
> +
> +#define PREP_MSG_VF_STATE_NOTIFY(mbz, vfid, e) \
> + PREP_MSG_0_VF_STATE_NOTIFY(mbz), \
> + FIELD_PREP_CONST(GUC2PF_VF_STATE_NOTIFY_EVENT_MSG_1_VFID, (vfid)), \
> + FIELD_PREP_CONST(GUC2PF_VF_STATE_NOTIFY_EVENT_MSG_2_EVENT, (e))
> +
> +static const u32 msg_pf_enable[] = {
> + PREP_MSG_VF_STATE_NOTIFY(0, 0, GUC_PF_NOTIFY_VF_ENABLE),
> +};
> +
> +static const u32 msg_vf_flr[] = {
> + PREP_MSG_VF_STATE_NOTIFY(0, VFUT1, GUC_PF_NOTIFY_VF_FLR),
> +};
> +
> +static const u32 msg_vf_flr_done[] = {
> + PREP_MSG_VF_STATE_NOTIFY(0, VFUT1, GUC_PF_NOTIFY_VF_FLR_DONE),
> +};
> +
> +static const u32 msg_vf_pause_done[] = {
> + PREP_MSG_VF_STATE_NOTIFY(0, VFUT1, GUC_PF_NOTIFY_VF_PAUSE_DONE),
> +};
> +
> +static const u32 msg_vf_fixup[] = {
> + PREP_MSG_VF_STATE_NOTIFY(0, VFUT1, GUC_PF_NOTIFY_VF_FIXUP_DONE),
> +};
> +
> +static const u32 msg_pf_bad_mbz[] = {
> + PREP_MSG_VF_STATE_NOTIFY(1, 0, GUC_PF_NOTIFY_VF_ENABLE),
> +};
> +
> +static const u32 msg_pf_invalid_event[] = {
> + PREP_MSG_VF_STATE_NOTIFY(0, 0, 0),
> +};
> +
> +static const u32 msg_pf_unknown_event[] = {
> + PREP_MSG_VF_STATE_NOTIFY(0, 0, GUC_PF_NOTIFY_VF_ENABLE + 1),
> +};
> +
> +static const u32 msg_vf_bad_mbz[] = {
> + PREP_MSG_VF_STATE_NOTIFY(1, VFUT1, GUC_PF_NOTIFY_VF_FLR),
> +};
> +
> +static const u32 msg_vf_bad_vfid[] = {
> + PREP_MSG_VF_STATE_NOTIFY(0, VFID(DUT_NUM_VFS + 1), GUC_PF_NOTIFY_VF_FLR),
> +};
> +
> +static const u32 msg_vf_invalid_event[] = {
> + PREP_MSG_VF_STATE_NOTIFY(0, VFUT1, 0),
> +};
> +
> +static const u32 msg_vf_unknown_event[] = {
> + PREP_MSG_VF_STATE_NOTIFY(0, VFUT1, GUC_PF_NOTIFY_VF_FIXUP_DONE + 1),
> +};
> +
> +static const u32 msg_no_data[GUC_HXG_EVENT_MSG_MIN_LEN] = {
> + PREP_MSG_0_VF_STATE_NOTIFY(0),
> + /* only header, missing both VFID and EVENT data */
> +};
> +
> +static const u32 msg_pf_too_short[GUC2PF_VF_STATE_NOTIFY_EVENT_MSG_LEN - 1] = {
> + PREP_MSG_0_VF_STATE_NOTIFY(0),
> + PFID,
> + /* missing EVENT data */
> +};
> +
> +static const u32 msg_pf_too_long[GUC2PF_VF_STATE_NOTIFY_EVENT_MSG_LEN + 1] = {
> + PREP_MSG_VF_STATE_NOTIFY(0, 0, GUC_PF_NOTIFY_VF_ENABLE),
> + 0, /* unexpected extra DATA */
> +};
> +
> +static const u32 msg_vf_too_short[GUC2PF_VF_STATE_NOTIFY_EVENT_MSG_LEN - 1] = {
> + PREP_MSG_0_VF_STATE_NOTIFY(0),
> + VFUT1,
> + /* missing EVENT data */
> +};
> +
> +static const u32 msg_vf_too_long[GUC2PF_VF_STATE_NOTIFY_EVENT_MSG_LEN + 1] = {
> + PREP_MSG_VF_STATE_NOTIFY(0, VFUT1, GUC_PF_NOTIFY_VF_FLR),
> + 0, /* unexpected extra DATA */
> +};
> +
> +struct msg_param {
> + const char *name;
> + const u32 *msg;
> + size_t len;
> +};
> +
> +static void msg_param_get_desc(struct msg_param *p, char *desc)
> +{
> + snprintf(desc, KUNIT_PARAM_DESC_SIZE, "%s", p->name);
> +}
> +
> +#define MAKE_MSG_PARAM(X) { .name = #X, .msg = X, .len = ARRAY_SIZE(X) }
> +
> +#define LIST_MSG_PARAM_VALID \
> + MAKE_MSG_PARAM(msg_pf_enable), \
> + MAKE_MSG_PARAM(msg_vf_flr), \
> + MAKE_MSG_PARAM(msg_vf_flr_done), \
> + MAKE_MSG_PARAM(msg_vf_pause_done), \
> + MAKE_MSG_PARAM(msg_vf_fixup)
> +
> +#define LIST_MSG_PARAM_INVALID \
> + MAKE_MSG_PARAM(msg_no_data), \
> + MAKE_MSG_PARAM(msg_pf_too_long), \
> + MAKE_MSG_PARAM(msg_pf_too_short), \
> + MAKE_MSG_PARAM(msg_pf_bad_mbz), \
> + MAKE_MSG_PARAM(msg_pf_invalid_event), \
> + MAKE_MSG_PARAM(msg_pf_unknown_event), \
> + MAKE_MSG_PARAM(msg_vf_too_long), \
> + MAKE_MSG_PARAM(msg_vf_too_short), \
> + MAKE_MSG_PARAM(msg_vf_bad_mbz), \
> + MAKE_MSG_PARAM(msg_vf_bad_vfid), \
> + MAKE_MSG_PARAM(msg_vf_invalid_event), \
> + MAKE_MSG_PARAM(msg_vf_unknown_event)
> +
> +static struct msg_param valid_messages[] = {
> + LIST_MSG_PARAM_VALID,
> +};
> +
> +static struct msg_param invalid_messages[] = {
> + LIST_MSG_PARAM_INVALID,
> +};
> +
> +static struct msg_param all_messages[] = {
> + LIST_MSG_PARAM_VALID,
> + LIST_MSG_PARAM_INVALID,
> +};
> +
> +KUNIT_ARRAY_PARAM(valid_messages, valid_messages, msg_param_get_desc);
> +KUNIT_ARRAY_PARAM(invalid_messages, invalid_messages, msg_param_get_desc);
> +KUNIT_ARRAY_PARAM(all_messages, all_messages, msg_param_get_desc);
> +
> +static void xe_rejects_all_g2h(struct kunit *test)
> +{
> + struct xe_device *xe = (xe_kunit_helper_xe_device_test_init(test), test->priv);
> + struct xe_gt *gt = xe_device_get_gt(xe, 0);
> + const struct msg_param *p = test->param_value;
> +
> + KUNIT_EXPECT_FALSE(test, IS_SRIOV_PF(xe));
> + KUNIT_EXPECT_EQ(test, -EPROTO, xe_gt_sriov_pf_control_process_guc2pf(gt, p->msg, p->len));
> +}
> +
> +static void vf_rejects_all_g2h(struct kunit *test)
> +{
> + struct xe_device *xe = (xe_kunit_helper_xe_device_test_init(test), test->priv);
> + struct xe_gt *gt = xe_device_get_gt(xe, 0);
> + const struct msg_param *p = test->param_value;
> +
> + KUNIT_EXPECT_FALSE(test, IS_SRIOV(xe));
> + xe->sriov.__mode = XE_SRIOV_MODE_VF;
> +
> + KUNIT_EXPECT_TRUE(test, IS_SRIOV_VF(xe));
> + KUNIT_EXPECT_EQ(test, -EPROTO, xe_gt_sriov_pf_control_process_guc2pf(gt, p->msg, p->len));
> +}
> +
> +static void pf_rejects_malformed_g2h(struct kunit *test)
> +{
> + struct xe_gt *gt = (pf_control_test_init(test), test->priv);
> + const struct msg_param *p = test->param_value;
> +
> + KUNIT_EXPECT_NE(test, 0, xe_gt_sriov_pf_control_process_guc2pf(gt, p->msg, p->len));
> +}
> +
> +static void pf_accepts_valid_g2h(struct kunit *test)
> +{
> + struct xe_gt *gt = (pf_control_test_init(test), test->priv);
> + const struct msg_param *p = test->param_value;
> +
> + XE_TEST_ACTIVATE_STUB(test, gt->sriov.pf.control.send_vf_control_cmd,
> + send_vf_control_cmd_pass_no_reply);
> +
> + KUNIT_EXPECT_EQ(test, 0, xe_gt_sriov_pf_control_process_guc2pf(gt, p->msg, p->len));
> +}
> +
> +static struct kunit_case pf_control_guc_test_cases[] = {
> + KUNIT_CASE_PARAM(xe_rejects_all_g2h, all_messages_gen_params),
> + KUNIT_CASE_PARAM(vf_rejects_all_g2h, all_messages_gen_params),
> + KUNIT_CASE_PARAM(pf_rejects_malformed_g2h, invalid_messages_gen_params),
> + KUNIT_CASE_PARAM(pf_accepts_valid_g2h, valid_messages_gen_params),
> + {}
> +};
> +
> +static struct kunit_suite pf_control_guc_suite = {
> + .name = "pf_control_guc",
> + .test_cases = pf_control_guc_test_cases,
> +};
> +
> +kunit_test_suite(pf_control_guc_suite);
LGTM:
Reviewed-by: Piotr Piórkowski <piotr.piorkowski@intel.com>
> --
> 2.43.0
>
--
next prev parent reply other threads:[~2024-08-23 13:18 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-09 16:51 [PATCH 00/12] PF: Improve VF control Michal Wajdeczko
2024-08-09 16:51 ` [PATCH 01/12] drm/xe/pf: Add function to sanitize VF resources Michal Wajdeczko
2024-08-16 12:58 ` Piotr Piórkowski
2024-08-19 20:47 ` Lucas De Marchi
2024-08-20 9:38 ` Michal Wajdeczko
2024-08-20 13:16 ` Lucas De Marchi
2024-09-05 18:07 ` Rodrigo Vivi
2024-08-09 16:51 ` [PATCH 02/12] drm/xe/pf: Fix documentation formatting Michal Wajdeczko
2024-08-16 12:59 ` Piotr Piórkowski
2024-08-09 16:51 ` [PATCH 03/12] drm/xe/pf: Drop GuC notifications for non-existing VF Michal Wajdeczko
2024-08-16 13:01 ` Piotr Piórkowski
2024-08-19 17:51 ` Michal Wajdeczko
2024-08-22 10:48 ` Piotr Piórkowski
2024-08-09 16:51 ` [PATCH 04/12] drm/xe/pf: Improve VF control Michal Wajdeczko
2024-08-16 13:06 ` Piotr Piórkowski
2024-08-19 17:52 ` Michal Wajdeczko
2024-08-20 7:56 ` Piotr Piórkowski
2024-08-20 10:04 ` Michal Wajdeczko
2024-08-09 16:51 ` [PATCH 05/12] drm/xe/tests: Allow deferred function call during KUnit test Michal Wajdeczko
2024-08-19 21:38 ` Lucas De Marchi
2024-08-20 10:23 ` Michal Wajdeczko
2024-08-20 13:21 ` Lucas De Marchi
2024-08-20 13:27 ` Lucas De Marchi
2024-08-09 16:51 ` [PATCH 06/12] drm/xe/tests: Add helper macro to detect if KUnit is running Michal Wajdeczko
2024-08-09 16:51 ` [PATCH 07/12] drm/xe/tests: Add helpers to call stubs out of KUnit context Michal Wajdeczko
2024-08-19 21:52 ` Lucas De Marchi
2024-08-20 10:31 ` Michal Wajdeczko
2024-08-09 16:51 ` [PATCH 08/12] drm/xe/guc: Define stub for xe_guc_ct_send_recv() Michal Wajdeczko
2024-08-09 16:51 ` [PATCH 09/12] drm/xe/pf: Define stub for pf_sanitize_vf_resources() Michal Wajdeczko
2024-08-09 16:51 ` [PATCH 10/12] drm/xe/pf: Define stub for pf_send_vf_control_cmd() Michal Wajdeczko
2024-08-09 16:51 ` [PATCH 11/12] drm/xe/tests: Add KUnit tests for VF control state machines Michal Wajdeczko
2024-08-09 17:23 ` [PATCH v2 " Michal Wajdeczko
2024-08-22 10:51 ` Piotr Piórkowski
2024-08-22 10:47 ` [PATCH " Piotr Piórkowski
2024-08-09 16:51 ` [PATCH 12/12] drm/xe/tests: Add KUnit tests for VF control GuC messages Michal Wajdeczko
2024-08-23 13:18 ` Piotr Piórkowski [this message]
2024-08-09 16:57 ` ✓ CI.Patch_applied: success for PF: Improve VF control Patchwork
2024-08-09 16:58 ` ✗ CI.checkpatch: warning " Patchwork
2024-08-09 16:58 ` ✗ CI.KUnit: failure " Patchwork
2024-08-09 17:28 ` ✓ CI.Patch_applied: success for PF: Improve VF control (rev2) Patchwork
2024-08-09 17:29 ` ✗ CI.checkpatch: warning " Patchwork
2024-08-09 17:30 ` ✓ CI.KUnit: success " Patchwork
2024-08-09 17:42 ` ✓ CI.Build: " Patchwork
2024-08-09 17:44 ` ✗ CI.Hooks: failure " Patchwork
2024-08-09 17:46 ` ✓ CI.checksparse: success " Patchwork
2024-08-09 18:06 ` ✓ CI.BAT: " Patchwork
2024-08-09 20:35 ` ✗ CI.FULL: failure " Patchwork
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=20240823131805.sf5rf2k3onbvez3p@intel.com \
--to=piotr.piorkowski@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lucas.demarchi@intel.com \
--cc=michal.wajdeczko@intel.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