netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhu Lingshan <lingshan.zhu@intel.com>
To: jasowang@redhat.com, mst@redhat.com
Cc: virtualization@lists.linux-foundation.org,
	netdev@vger.kernel.org, kvm@vger.kernel.org,
	Zhu Lingshan <lingshan.zhu@intel.com>
Subject: [RFC 1/4] vDPA/ifcvf: add get/set_vq_endian support for vDPA
Date: Thu,  1 Sep 2022 18:15:58 +0800	[thread overview]
Message-ID: <20220901101601.61420-2-lingshan.zhu@intel.com> (raw)
In-Reply-To: <20220901101601.61420-1-lingshan.zhu@intel.com>

This commit introuduces new config operatoions for vDPA:
vdpa_config_ops.get_vq_endian: set vq endian-ness
vdpa_config_ops.set_vq_endian: get vq endian-ness

Because the endian-ness is a device wide attribute,
so seting a vq's endian-ness will result in changing
the device endian-ness, including all vqs and the config space.

These two operations are implemented in ifcvf in this commit.

Signed-off-by: Zhu Lingshan <lingshan.zhu@intel.com>
---
 drivers/vdpa/ifcvf/ifcvf_base.h |  1 +
 drivers/vdpa/ifcvf/ifcvf_main.c | 15 +++++++++++++++
 include/linux/vdpa.h            | 13 +++++++++++++
 3 files changed, 29 insertions(+)

diff --git a/drivers/vdpa/ifcvf/ifcvf_base.h b/drivers/vdpa/ifcvf/ifcvf_base.h
index f5563f665cc6..640238b95033 100644
--- a/drivers/vdpa/ifcvf/ifcvf_base.h
+++ b/drivers/vdpa/ifcvf/ifcvf_base.h
@@ -19,6 +19,7 @@
 #include <uapi/linux/virtio_blk.h>
 #include <uapi/linux/virtio_config.h>
 #include <uapi/linux/virtio_pci.h>
+#include <uapi/linux/vhost.h>
 
 #define N3000_DEVICE_ID		0x1041
 #define N3000_SUBSYS_DEVICE_ID	0x001A
diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c
index f9c0044c6442..270637d0f3a5 100644
--- a/drivers/vdpa/ifcvf/ifcvf_main.c
+++ b/drivers/vdpa/ifcvf/ifcvf_main.c
@@ -684,6 +684,19 @@ static struct vdpa_notification_area ifcvf_get_vq_notification(struct vdpa_devic
 	return area;
 }
 
+static u8 ifcvf_vdpa_get_vq_endian(struct vdpa_device *vdpa_dev, u16 idx)
+{
+	return VHOST_VRING_LITTLE_ENDIAN;
+}
+
+static int ifcvf_vdpa_set_vq_endian(struct vdpa_device *vdpa_dev, u16 idx, u8 endian)
+{
+	if (endian != VHOST_VRING_LITTLE_ENDIAN)
+		return -EFAULT;
+
+	return 0;
+}
+
 /*
  * IFCVF currently doesn't have on-chip IOMMU, so not
  * implemented set_map()/dma_map()/dma_unmap()
@@ -715,6 +728,8 @@ static const struct vdpa_config_ops ifc_vdpa_ops = {
 	.set_config	= ifcvf_vdpa_set_config,
 	.set_config_cb  = ifcvf_vdpa_set_config_cb,
 	.get_vq_notification = ifcvf_get_vq_notification,
+	.get_vq_endian	= ifcvf_vdpa_get_vq_endian,
+	.set_vq_endian	= ifcvf_vdpa_set_vq_endian,
 };
 
 static struct virtio_device_id id_table_net[] = {
diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h
index d282f464d2f1..5eb83453ba86 100644
--- a/include/linux/vdpa.h
+++ b/include/linux/vdpa.h
@@ -174,6 +174,17 @@ struct vdpa_map_file {
  *				@idx: virtqueue index
  *				Returns int: irq number of a virtqueue,
  *				negative number if no irq assigned.
+ * @set_vq_endian:		set endian-ness for a virtqueue
+ *				@vdev: vdpa device
+ *				@idx: virtqueue index
+ *				@endian: the endian-ness to set,
+ *				can be VHOST_VRING_LITTLE_ENDIAN or VHOST_VRING_BIG_ENDIAN
+ *				Returns integer: success (0) or error (< 0)
+ * @get_vq_endian:		get the endian-ness of a virtqueue
+ *				@vdev: vdpa device
+ *				@idx: virtqueue index
+ *				Returns u8, the endian-ness of the virtqueue,
+ *				can be VHOST_VRING_LITTLE_ENDIAN or VHOST_VRING_BIG_ENDIAN
  * @get_vq_align:		Get the virtqueue align requirement
  *				for the device
  *				@vdev: vdpa device
@@ -306,6 +317,8 @@ struct vdpa_config_ops {
 	(*get_vq_notification)(struct vdpa_device *vdev, u16 idx);
 	/* vq irq is not expected to be changed once DRIVER_OK is set */
 	int (*get_vq_irq)(struct vdpa_device *vdev, u16 idx);
+	int (*set_vq_endian)(struct vdpa_device *vdev, u16 idx, u8 endian);
+	u8 (*get_vq_endian)(struct vdpa_device *vdev, u16 idx);
 
 	/* Device ops */
 	u32 (*get_vq_align)(struct vdpa_device *vdev);
-- 
2.31.1


  reply	other threads:[~2022-09-01 10:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-01 10:15 [RFC 0/4] vDPA: support VHOST_GET/SET_VRING_ENDIAN Zhu Lingshan
2022-09-01 10:15 ` Zhu Lingshan [this message]
2022-09-05  8:34   ` [RFC 1/4] vDPA/ifcvf: add get/set_vq_endian support for vDPA Jason Wang
2022-09-06  2:12     ` Zhu, Lingshan
2022-09-01 10:15 ` [RFC 2/4] vDPA: support ioctl VHOST_GET/SET_VRING_ENDIAN Zhu Lingshan
2022-09-01 10:16 ` [RFC 3/4] vDPA: detect device endian in _net_config_fill() and _fill_stats_rec() Zhu Lingshan
2022-09-01 10:16 ` [RFC 4/4] vDPA: report device endian-ness to userspace through netlink Zhu Lingshan

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=20220901101601.61420-2-lingshan.zhu@intel.com \
    --to=lingshan.zhu@intel.com \
    --cc=jasowang@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    /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;
as well as URLs for NNTP newsgroup(s).