common/sfc_efx/base: support verifying virtio features

Add an API to verify virtio features supported by device.

Signed-off-by: Vijay Kumar Srivastava <vsrivast@xilinx.com>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
This commit is contained in:
Vijay Kumar Srivastava 2021-03-16 11:58:29 +03:00 committed by Ferruh Yigit
parent 46d2b38ba9
commit b8a896ab97
5 changed files with 98 additions and 0 deletions

View File

@ -4501,6 +4501,13 @@ efx_virtio_get_features(
__in efx_virtio_device_type_t type,
__out uint64_t *featuresp);
LIBEFX_API
extern __checkReturn efx_rc_t
efx_virtio_verify_features(
__in efx_nic_t *enp,
__in efx_virtio_device_type_t type,
__in uint64_t features);
#endif /* EFSYS_OPT_VIRTIO */
#ifdef __cplusplus

View File

@ -320,6 +320,8 @@ typedef struct efx_virtio_ops_s {
uint32_t *);
efx_rc_t (*evo_get_features)(efx_nic_t *,
efx_virtio_device_type_t, uint64_t *);
efx_rc_t (*evo_verify_features)(efx_nic_t *,
efx_virtio_device_type_t, uint64_t);
} efx_virtio_ops_t;
#endif /* EFSYS_OPT_VIRTIO */

View File

@ -14,6 +14,7 @@ static const efx_virtio_ops_t __efx_virtio_rhead_ops = {
rhead_virtio_qstop, /* evo_virtio_qstop */
rhead_virtio_get_doorbell_offset, /* evo_get_doorbell_offset */
rhead_virtio_get_features, /* evo_get_features */
rhead_virtio_verify_features, /* evo_verify_features */
};
#endif /* EFSYS_OPT_RIVERHEAD */
@ -299,4 +300,41 @@ fail1:
return (rc);
}
__checkReturn efx_rc_t
efx_virtio_verify_features(
__in efx_nic_t *enp,
__in efx_virtio_device_type_t type,
__in uint64_t features)
{
const efx_virtio_ops_t *evop = enp->en_evop;
efx_rc_t rc;
if (type >= EFX_VIRTIO_DEVICE_NTYPES) {
rc = EINVAL;
goto fail1;
}
EFSYS_ASSERT3U(enp->en_magic, ==, EFX_NIC_MAGIC);
EFSYS_ASSERT3U(enp->en_mod_flags, &, EFX_MOD_VIRTIO);
if (evop == NULL) {
rc = ENOTSUP;
goto fail2;
}
if ((rc = evop->evo_verify_features(enp, type, features)) != 0)
goto fail3;
return (0);
fail3:
EFSYS_PROBE(fail3);
fail2:
EFSYS_PROBE(fail2);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
#endif /* EFSYS_OPT_VIRTIO */

View File

@ -505,6 +505,13 @@ rhead_virtio_get_features(
__in efx_virtio_device_type_t type,
__out uint64_t *featuresp);
LIBEFX_INTERNAL
extern __checkReturn efx_rc_t
rhead_virtio_verify_features(
__in efx_nic_t *enp,
__in efx_virtio_device_type_t type,
__in uint64_t features);
#endif /* EFSYS_OPT_VIRTIO */
#ifdef __cplusplus

View File

@ -332,4 +332,48 @@ fail1:
return (rc);
}
__checkReturn efx_rc_t
rhead_virtio_verify_features(
__in efx_nic_t *enp,
__in efx_virtio_device_type_t type,
__in uint64_t features)
{
efx_mcdi_req_t req;
EFX_MCDI_DECLARE_BUF(payload, MC_CMD_VIRTIO_TEST_FEATURES_IN_LEN,
MC_CMD_VIRTIO_TEST_FEATURES_OUT_LEN);
efx_rc_t rc;
EFX_STATIC_ASSERT(EFX_VIRTIO_DEVICE_TYPE_NET ==
MC_CMD_VIRTIO_GET_FEATURES_IN_NET);
EFX_STATIC_ASSERT(EFX_VIRTIO_DEVICE_TYPE_BLOCK ==
MC_CMD_VIRTIO_GET_FEATURES_IN_BLOCK);
req.emr_cmd = MC_CMD_VIRTIO_TEST_FEATURES;
req.emr_in_buf = payload;
req.emr_in_length = MC_CMD_VIRTIO_TEST_FEATURES_IN_LEN;
req.emr_out_buf = payload;
req.emr_out_length = MC_CMD_VIRTIO_TEST_FEATURES_OUT_LEN;
MCDI_IN_SET_DWORD(req, VIRTIO_TEST_FEATURES_IN_DEVICE_ID, type);
MCDI_IN_SET_DWORD(req, VIRTIO_TEST_FEATURES_IN_FEATURES_LO,
features & 0xFFFFFFFF);
MCDI_IN_SET_DWORD(req, VIRTIO_TEST_FEATURES_IN_FEATURES_HI,
((features >> 32) & 0xFFFFFFFF));
efx_mcdi_execute(enp, &req);
if (req.emr_rc != 0) {
rc = req.emr_rc;
goto fail1;
}
return (0);
fail1:
EFSYS_PROBE1(fail1, efx_rc_t, rc);
return (rc);
}
#endif /* EFSYS_OPT_RIVERHEAD && EFSYS_OPT_VIRTIO */