DPDK patches and discussions
 help / color / mirror / Atom feed
From: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
To: Ferruh Yigit <ferruh.yigit@intel.com>
Cc: dev@dpdk.org, Vijay Srivastava <vijays@solarflare.com>
Subject: [dpdk-dev] [PATCH v4 2/8] common/sfc_efx/base: add API to get VirtQ doorbell offset
Date: Tue, 16 Mar 2021 11:58:26 +0300
Message-ID: <20210316085832.942481-3-andrew.rybchenko@oktetlabs.ru> (raw)
In-Reply-To: <20210316085832.942481-1-andrew.rybchenko@oktetlabs.ru>

From: Vijay Srivastava <vijays@solarflare.com>

Add an API to query the virtqueue doorbell offset in the BAR for a VI.
For vDPA, the virtio net driver notifies the device directly by writing
doorbell. This API would be invoked from vDPA client driver.

Signed-off-by: Vijay Srivastava <vijays@solarflare.com>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
---
 drivers/common/sfc_efx/base/efx.h          | 12 +++
 drivers/common/sfc_efx/base/efx_impl.h     |  2 +
 drivers/common/sfc_efx/base/efx_virtio.c   | 41 ++++++++++
 drivers/common/sfc_efx/base/rhead_impl.h   |  6 ++
 drivers/common/sfc_efx/base/rhead_virtio.c | 93 ++++++++++++++++++++++
 5 files changed, 154 insertions(+)

diff --git a/drivers/common/sfc_efx/base/efx.h b/drivers/common/sfc_efx/base/efx.h
index c2c73bd382..d4b7d7f47e 100644
--- a/drivers/common/sfc_efx/base/efx.h
+++ b/drivers/common/sfc_efx/base/efx.h
@@ -4475,6 +4475,18 @@ extern			void
 efx_virtio_qdestroy(
 	__in		efx_virtio_vq_t *evvp);
 
+/*
+ * Get the offset in the BAR of the doorbells for a VI.
+ * net device : doorbell offset of RX & TX queues
+ * block device : request doorbell offset in the BAR.
+ * For further details refer section of 4 of SF-119689
+ */
+LIBEFX_API
+extern	__checkReturn	efx_rc_t
+efx_virtio_get_doorbell_offset(
+	__in		efx_virtio_vq_t *evvp,
+	__out		uint32_t *offsetp);
+
 #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 f27d9fa82c..d6742f4a8c 100644
--- a/drivers/common/sfc_efx/base/efx_impl.h
+++ b/drivers/common/sfc_efx/base/efx_impl.h
@@ -316,6 +316,8 @@ typedef struct efx_virtio_ops_s {
 				efx_virtio_vq_dyncfg_t *);
 	efx_rc_t	(*evo_virtio_qstop)(efx_virtio_vq_t *,
 				efx_virtio_vq_dyncfg_t *);
+	efx_rc_t	(*evo_get_doorbell_offset)(efx_virtio_vq_t *,
+				uint32_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 68d157bea6..7303c00a0c 100644
--- a/drivers/common/sfc_efx/base/efx_virtio.c
+++ b/drivers/common/sfc_efx/base/efx_virtio.c
@@ -12,6 +12,7 @@
 static const efx_virtio_ops_t	__efx_virtio_rhead_ops = {
 	rhead_virtio_qstart,			/* evo_virtio_qstart */
 	rhead_virtio_qstop,			/* evo_virtio_qstop */
+	rhead_virtio_get_doorbell_offset,	/* evo_get_doorbell_offset */
 };
 #endif /* EFSYS_OPT_RIVERHEAD */
 
@@ -213,4 +214,44 @@ efx_virtio_qdestroy(
 	}
 }
 
+	__checkReturn	efx_rc_t
+efx_virtio_get_doorbell_offset(
+	__in		efx_virtio_vq_t *evvp,
+	__out		uint32_t *offsetp)
+{
+	efx_nic_t *enp;
+	const efx_virtio_ops_t *evop;
+	efx_rc_t rc;
+
+	if ((evvp == NULL) || (offsetp == NULL)) {
+		rc = EINVAL;
+		goto fail1;
+	}
+
+	enp = evvp->evv_enp;
+	evop = enp->en_evop;
+
+	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_get_doorbell_offset(evvp, offsetp)) != 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 a15ac52a58..4304f63f4c 100644
--- a/drivers/common/sfc_efx/base/rhead_impl.h
+++ b/drivers/common/sfc_efx/base/rhead_impl.h
@@ -492,6 +492,12 @@ rhead_virtio_qstop(
 	__in				efx_virtio_vq_t *evvp,
 	__out_opt			efx_virtio_vq_dyncfg_t *evvdp);
 
+LIBEFX_INTERNAL
+extern	__checkReturn			efx_rc_t
+rhead_virtio_get_doorbell_offset(
+	__in				efx_virtio_vq_t *evvp,
+	__out				uint32_t *offsetp);
+
 #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 ab83b24a45..e69671394a 100644
--- a/drivers/common/sfc_efx/base/rhead_virtio.c
+++ b/drivers/common/sfc_efx/base/rhead_virtio.c
@@ -187,4 +187,97 @@ rhead_virtio_qstop(
 	return (rc);
 }
 
+	__checkReturn	efx_rc_t
+rhead_virtio_get_doorbell_offset(
+	__in		efx_virtio_vq_t *evvp,
+	__out		uint32_t *offsetp)
+{
+	efx_nic_t *enp = evvp->evv_enp;
+	efx_mcdi_req_t req;
+	uint32_t type;
+	EFX_MCDI_DECLARE_BUF(payload, MC_CMD_VIRTIO_GET_DOORBELL_OFFSET_REQ_LEN,
+		MC_CMD_VIRTIO_GET_NET_DOORBELL_OFFSET_RESP_LEN);
+	efx_rc_t rc;
+
+	req.emr_cmd = MC_CMD_VIRTIO_GET_DOORBELL_OFFSET;
+	req.emr_in_buf = payload;
+	req.emr_in_length = MC_CMD_VIRTIO_GET_DOORBELL_OFFSET_REQ_LEN;
+	req.emr_out_buf = payload;
+	req.emr_out_length = MC_CMD_VIRTIO_GET_NET_DOORBELL_OFFSET_RESP_LEN;
+
+	switch (evvp->evv_type) {
+	case EFX_VIRTIO_VQ_TYPE_NET_RXQ:
+	case EFX_VIRTIO_VQ_TYPE_NET_TXQ:
+		type = MC_CMD_VIRTIO_GET_FEATURES_IN_NET;
+		break;
+	case EFX_VIRTIO_VQ_TYPE_BLOCK:
+		type = MC_CMD_VIRTIO_GET_FEATURES_IN_BLOCK;
+		break;
+	default:
+		rc = EINVAL;
+		goto fail1;
+	}
+
+	MCDI_IN_SET_BYTE(req, VIRTIO_GET_DOORBELL_OFFSET_REQ_DEVICE_ID,
+		type);
+	MCDI_IN_SET_WORD(req, VIRTIO_GET_DOORBELL_OFFSET_REQ_TARGET_VF,
+		evvp->evv_target_vf);
+	MCDI_IN_SET_DWORD(req, VIRTIO_GET_DOORBELL_OFFSET_REQ_INSTANCE,
+		evvp->evv_vi_index);
+
+	efx_mcdi_execute(enp, &req);
+
+	if (req.emr_rc != 0) {
+		rc = req.emr_rc;
+		goto fail2;
+	}
+
+	switch (type) {
+	case MC_CMD_VIRTIO_GET_FEATURES_IN_NET:
+		if (req.emr_out_length_used <
+		    MC_CMD_VIRTIO_GET_NET_DOORBELL_OFFSET_RESP_LEN) {
+			rc = EMSGSIZE;
+			goto fail3;
+		}
+
+		if (evvp->evv_type == EFX_VIRTIO_VQ_TYPE_NET_RXQ) {
+			*offsetp = MCDI_OUT_DWORD(req,
+			    VIRTIO_GET_NET_DOORBELL_OFFSET_RESP_RX_DBL_OFFSET);
+		} else if (evvp->evv_type == EFX_VIRTIO_VQ_TYPE_NET_TXQ) {
+			*offsetp = MCDI_OUT_DWORD(req,
+			    VIRTIO_GET_NET_DOORBELL_OFFSET_RESP_TX_DBL_OFFSET);
+		}
+		break;
+	case MC_CMD_VIRTIO_GET_FEATURES_IN_BLOCK:
+		if (req.emr_out_length_used <
+		    MC_CMD_VIRTIO_GET_BLOCK_DOORBELL_OFFSET_RESP_LEN) {
+			rc = EMSGSIZE;
+			goto fail4;
+		}
+
+		*offsetp = MCDI_OUT_DWORD(req,
+			VIRTIO_GET_BLOCK_DOORBELL_OFFSET_RESP_DBL_OFFSET);
+		break;
+	default:
+		EFSYS_ASSERT(0);
+		rc = EINVAL;
+		goto fail5;
+	}
+
+	return (0);
+
+fail5:
+	EFSYS_PROBE(fail5);
+fail4:
+	EFSYS_PROBE(fail4);
+fail3:
+	EFSYS_PROBE(fail3);
+fail2:
+	EFSYS_PROBE(fail2);
+fail1:
+	EFSYS_PROBE1(fail1, efx_rc_t, rc);
+
+	return (rc);
+}
+
 #endif	/* EFSYS_OPT_RIVERHEAD && EFSYS_OPT_VIRTIO */
-- 
2.30.1


  parent reply	other threads:[~2021-03-16  8:58 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-11 11:03 [dpdk-dev] [PATCH 0/8] common/sfc_efx: prepare to introduce vDPA driver Andrew Rybchenko
2021-03-11 11:03 ` [dpdk-dev] [PATCH 1/8] common/sfc_efx/base: add base virtio support for vDPA Andrew Rybchenko
2021-03-11 11:03 ` [dpdk-dev] [PATCH 2/8] common/sfc_efx/base: add API to get VirtQ doorbell offset Andrew Rybchenko
2021-03-11 11:03 ` [dpdk-dev] [PATCH 3/8] common/sfc_efx/base: add virtio build dependency Andrew Rybchenko
2021-03-11 11:03 ` [dpdk-dev] [PATCH 4/8] common/sfc_efx/base: add support to get virtio features Andrew Rybchenko
2021-03-11 11:03 ` [dpdk-dev] [PATCH 5/8] common/sfc_efx/base: add support to verify " Andrew Rybchenko
2021-03-11 11:03 ` [dpdk-dev] [PATCH 6/8] common/sfc_efx: add support to get the device class Andrew Rybchenko
2021-03-11 11:03 ` [dpdk-dev] [PATCH 7/8] net/sfc: skip driver probe for incompatible " Andrew Rybchenko
2021-03-11 11:03 ` [dpdk-dev] [PATCH 8/8] drivers: add common driver API to get efx family Andrew Rybchenko
2021-03-14  0:36   ` Ferruh Yigit
2021-03-15 14:01     ` Andrew Rybchenko
2021-03-15 13:58 ` [dpdk-dev] [PATCH v2 0/8] common/sfc_efx: prepare to introduce vDPA driver Andrew Rybchenko
2021-03-15 13:58   ` [dpdk-dev] [PATCH v2 1/8] common/sfc_efx/base: add base virtio support for vDPA Andrew Rybchenko
2021-03-15 13:58   ` [dpdk-dev] [PATCH v2 2/8] common/sfc_efx/base: add API to get VirtQ doorbell offset Andrew Rybchenko
2021-03-15 13:58   ` [dpdk-dev] [PATCH v2 3/8] common/sfc_efx/base: add virtio build dependency Andrew Rybchenko
2021-03-15 13:58   ` [dpdk-dev] [PATCH v2 4/8] common/sfc_efx/base: add support to get virtio features Andrew Rybchenko
2021-03-15 13:58   ` [dpdk-dev] [PATCH v2 5/8] common/sfc_efx/base: add support to verify " Andrew Rybchenko
2021-03-15 13:58   ` [dpdk-dev] [PATCH v2 6/8] common/sfc_efx: add support to get the device class Andrew Rybchenko
2021-03-15 13:58   ` [dpdk-dev] [PATCH v2 7/8] net/sfc: skip driver probe for incompatible " Andrew Rybchenko
2021-03-15 13:58   ` [dpdk-dev] [PATCH v2 8/8] drivers: add common driver API to get efx family Andrew Rybchenko
2021-03-15 15:54   ` [dpdk-dev] [PATCH v2 0/8] common/sfc_efx: prepare to introduce vDPA driver Ferruh Yigit
2021-03-16  7:25     ` Andrew Rybchenko
2021-03-16  6:15 ` [dpdk-dev] [PATCH v3 " Andrew Rybchenko
2021-03-16  6:15   ` [dpdk-dev] [PATCH v3 1/8] common/sfc_efx/base: add base virtio support for vDPA Andrew Rybchenko
2021-03-16  6:15   ` [dpdk-dev] [PATCH v3 2/8] common/sfc_efx/base: add API to get VirtQ doorbell offset Andrew Rybchenko
2021-03-16  6:15   ` [dpdk-dev] [PATCH v3 3/8] common/sfc_efx/base: add virtio build dependency Andrew Rybchenko
2021-03-16  6:15   ` [dpdk-dev] [PATCH v3 4/8] common/sfc_efx/base: add support to get virtio features Andrew Rybchenko
2021-03-16  6:15   ` [dpdk-dev] [PATCH v3 5/8] common/sfc_efx/base: add support to verify " Andrew Rybchenko
2021-03-16  6:15   ` [dpdk-dev] [PATCH v3 6/8] common/sfc_efx: add support to get the device class Andrew Rybchenko
2021-03-16  6:15   ` [dpdk-dev] [PATCH v3 7/8] net/sfc: skip driver probe for incompatible " Andrew Rybchenko
2021-03-16  6:15   ` [dpdk-dev] [PATCH v3 8/8] drivers: add common driver API to get efx family Andrew Rybchenko
2021-03-16  8:55   ` [dpdk-dev] [PATCH v3 0/8] common/sfc_efx: prepare to introduce vDPA driver Andrew Rybchenko
2021-03-16  8:58 ` [dpdk-dev] [PATCH v4 " Andrew Rybchenko
2021-03-16  8:58   ` [dpdk-dev] [PATCH v4 1/8] common/sfc_efx/base: add base virtio support for vDPA Andrew Rybchenko
2021-03-16 11:30     ` Ferruh Yigit
2021-03-16 11:47       ` Andrew Rybchenko
2021-03-16 11:58         ` Ferruh Yigit
2021-03-16 12:14           ` Andrew Rybchenko
2021-03-16 12:41             ` Ferruh Yigit
2021-03-16  8:58   ` Andrew Rybchenko [this message]
2021-03-16  8:58   ` [dpdk-dev] [PATCH v4 3/8] common/sfc_efx/base: add virtio build dependency Andrew Rybchenko
2021-03-16  8:58   ` [dpdk-dev] [PATCH v4 4/8] common/sfc_efx/base: add support to get virtio features Andrew Rybchenko
2021-03-16  8:58   ` [dpdk-dev] [PATCH v4 5/8] common/sfc_efx/base: add support to verify " Andrew Rybchenko
2021-03-16  8:58   ` [dpdk-dev] [PATCH v4 6/8] common/sfc_efx: add support to get the device class Andrew Rybchenko
2021-03-16  8:58   ` [dpdk-dev] [PATCH v4 7/8] net/sfc: skip driver probe for incompatible " Andrew Rybchenko
2021-03-16  8:58   ` [dpdk-dev] [PATCH v4 8/8] drivers: add common driver API to get efx family Andrew Rybchenko
2021-03-16 11:26   ` [dpdk-dev] [PATCH v4 0/8] common/sfc_efx: prepare to introduce vDPA driver Ferruh Yigit
2021-03-16 11:30     ` Andrew Rybchenko
2021-03-16 11:32       ` Ferruh Yigit
2021-03-16 11:34         ` Ferruh Yigit
2021-03-16 11:46   ` Ferruh Yigit

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=20210316085832.942481-3-andrew.rybchenko@oktetlabs.ru \
    --to=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=vijays@solarflare.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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git