From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 31676A056A; Thu, 11 Mar 2021 12:04:29 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 6E7E522A40A; Thu, 11 Mar 2021 12:03:52 +0100 (CET) Received: from shelob.oktetlabs.ru (shelob.oktetlabs.ru [91.220.146.113]) by mails.dpdk.org (Postfix) with ESMTP id 6510B22A3BC for ; Thu, 11 Mar 2021 12:03:48 +0100 (CET) Received: by shelob.oktetlabs.ru (Postfix, from userid 122) id 38EFD7F5BD; Thu, 11 Mar 2021 14:03:48 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shelob.oktetlabs.ru X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=ALL_TRUSTED, DKIM_ADSP_DISCARD, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from aros.oktetlabs.ru (aros.oktetlabs.ru [192.168.38.17]) by shelob.oktetlabs.ru (Postfix) with ESMTP id 512407F5AE; Thu, 11 Mar 2021 14:03:36 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 shelob.oktetlabs.ru 512407F5AE Authentication-Results: shelob.oktetlabs.ru/512407F5AE; dkim=none; dkim-atps=neutral From: Andrew Rybchenko To: dev@dpdk.org Cc: Vijay Kumar Srivastava Date: Thu, 11 Mar 2021 14:03:22 +0300 Message-Id: <20210311110325.3291203-6-andrew.rybchenko@oktetlabs.ru> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210311110325.3291203-1-andrew.rybchenko@oktetlabs.ru> References: <20210311110325.3291203-1-andrew.rybchenko@oktetlabs.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 5/8] common/sfc_efx/base: add support to verify virtio features X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Vijay Kumar Srivastava Add an API to verify virtio features supported by device. Signed-off-by: Vijay Kumar Srivastava Signed-off-by: Andrew Rybchenko --- drivers/common/sfc_efx/base/efx.h | 7 ++++ drivers/common/sfc_efx/base/efx_impl.h | 2 + drivers/common/sfc_efx/base/efx_virtio.c | 38 +++++++++++++++++++ drivers/common/sfc_efx/base/rhead_impl.h | 7 ++++ drivers/common/sfc_efx/base/rhead_virtio.c | 44 ++++++++++++++++++++++ drivers/common/sfc_efx/version.map | 1 + 6 files changed, 99 insertions(+) diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h index ded6c4cac3..f3b386177d 100644 --- a/drivers/common/sfc_efx/base/efx.h +++ b/drivers/common/sfc_efx/base/efx.h @@ -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 diff --git a/drivers/common/sfc_efx/base/efx_impl.h b/drivers/common/sfc_efx/base/efx_impl.h index ba24babddd..94c730f4f5 100644 --- a/drivers/common/sfc_efx/base/efx_impl.h +++ b/drivers/common/sfc_efx/base/efx_impl.h @@ -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 */ diff --git a/drivers/common/sfc_efx/base/efx_virtio.c b/drivers/common/sfc_efx/base/efx_virtio.c index 20c22f02b5..b46997c09e 100644 --- a/drivers/common/sfc_efx/base/efx_virtio.c +++ b/drivers/common/sfc_efx/base/efx_virtio.c @@ -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 @@ efx_virtio_get_features( 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 */ diff --git a/drivers/common/sfc_efx/base/rhead_impl.h b/drivers/common/sfc_efx/base/rhead_impl.h index 2d69cf02e6..2e696a259f 100644 --- a/drivers/common/sfc_efx/base/rhead_impl.h +++ b/drivers/common/sfc_efx/base/rhead_impl.h @@ -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 diff --git a/drivers/common/sfc_efx/base/rhead_virtio.c b/drivers/common/sfc_efx/base/rhead_virtio.c index 508d03d58f..0023ea1e83 100644 --- a/drivers/common/sfc_efx/base/rhead_virtio.c +++ b/drivers/common/sfc_efx/base/rhead_virtio.c @@ -332,4 +332,48 @@ rhead_virtio_get_features( 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 */ diff --git a/drivers/common/sfc_efx/version.map b/drivers/common/sfc_efx/version.map index 01be45e9e9..fd275104e4 100644 --- a/drivers/common/sfc_efx/version.map +++ b/drivers/common/sfc_efx/version.map @@ -229,6 +229,7 @@ INTERNAL { efx_virtio_qdestroy; efx_virtio_qstart; efx_virtio_qstop; + efx_virtio_verify_features; sfc_efx_mcdi_init; sfc_efx_mcdi_fini; -- 2.30.1