From: Eli Cohen <eli@mellanox.com>
To: mst@redhat.com, jasowang@redhat.com,
virtualization@lists.linux-foundation.org,
linux-kernel@vger.kernel.org
Cc: shahafs@mellanox.com, saeedm@mellanox.com,
Max Gurtovoy <maxg@mellanox.com>
Subject: [PATCH vhost next 03/10] vdpa: remove hard coded virtq num
Date: Thu, 16 Jul 2020 10:23:20 +0300 [thread overview]
Message-ID: <20200716072327.5359-4-eli@mellanox.com> (raw)
In-Reply-To: <20200716072327.5359-1-eli@mellanox.com>
From: Max Gurtovoy <maxg@mellanox.com>
This will enable vdpa providers to add support for multi queue feature
and publish it to upper layers (vhost and virtio).
Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
---
drivers/vdpa/ifcvf/ifcvf_main.c | 3 ++-
drivers/vdpa/vdpa.c | 3 +++
drivers/vdpa/vdpa_sim/vdpa_sim.c | 4 ++--
drivers/vhost/vdpa.c | 9 +++------
include/linux/vdpa.h | 6 ++++--
5 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/drivers/vdpa/ifcvf/ifcvf_main.c b/drivers/vdpa/ifcvf/ifcvf_main.c
index f5a60c14b979..e0d43f25fc88 100644
--- a/drivers/vdpa/ifcvf/ifcvf_main.c
+++ b/drivers/vdpa/ifcvf/ifcvf_main.c
@@ -420,7 +420,8 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
}
adapter = vdpa_alloc_device(struct ifcvf_adapter, vdpa,
- dev, &ifc_vdpa_ops);
+ dev, &ifc_vdpa_ops,
+ IFCVF_MAX_QUEUE_PAIRS * 2);
if (adapter == NULL) {
IFCVF_ERR(pdev, "Failed to allocate vDPA structure");
return -ENOMEM;
diff --git a/drivers/vdpa/vdpa.c b/drivers/vdpa/vdpa.c
index de211ef3738c..f9c59f023d6d 100644
--- a/drivers/vdpa/vdpa.c
+++ b/drivers/vdpa/vdpa.c
@@ -61,6 +61,7 @@ static void vdpa_release_dev(struct device *d)
* initialized but before registered.
* @parent: the parent device
* @config: the bus operations that is supported by this device
+ * @nvqs: number of virtqueues supported by this device
* @size: size of the parent structure that contains private data
*
* Driver should use vdpa_alloc_device() wrapper macro instead of
@@ -71,6 +72,7 @@ static void vdpa_release_dev(struct device *d)
*/
struct vdpa_device *__vdpa_alloc_device(struct device *parent,
const struct vdpa_config_ops *config,
+ int nvqs,
size_t size)
{
struct vdpa_device *vdev;
@@ -96,6 +98,7 @@ struct vdpa_device *__vdpa_alloc_device(struct device *parent,
vdev->dev.release = vdpa_release_dev;
vdev->index = err;
vdev->config = config;
+ vdev->nvqs = nvqs;
err = dev_set_name(&vdev->dev, "vdpa%u", vdev->index);
if (err)
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.c b/drivers/vdpa/vdpa_sim/vdpa_sim.c
index 82d1068af3ef..a38d8dc12192 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.c
@@ -60,7 +60,7 @@ static u64 vdpasim_features = (1ULL << VIRTIO_F_ANY_LAYOUT) |
/* State of each vdpasim device */
struct vdpasim {
struct vdpa_device vdpa;
- struct vdpasim_virtqueue vqs[2];
+ struct vdpasim_virtqueue vqs[VDPASIM_VQ_NUM];
struct work_struct work;
/* spinlock to synchronize virtqueue state */
spinlock_t lock;
@@ -312,7 +312,7 @@ static struct vdpasim *vdpasim_create(void)
int ret = -ENOMEM;
vdpasim = vdpa_alloc_device(struct vdpasim, vdpa, NULL,
- &vdpasim_net_config_ops);
+ &vdpasim_net_config_ops, VDPASIM_VQ_NUM);
if (!vdpasim)
goto err_alloc;
diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index 65195b30133b..78f9d90c23b1 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -55,9 +55,6 @@ enum {
(1ULL << VIRTIO_NET_F_SPEED_DUPLEX),
};
-/* Currently, only network backend w/o multiqueue is supported. */
-#define VHOST_VDPA_VQ_MAX 2
-
#define VHOST_VDPA_DEV_MAX (1U << MINORBITS)
struct vhost_vdpa {
@@ -882,7 +879,7 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa)
{
const struct vdpa_config_ops *ops = vdpa->config;
struct vhost_vdpa *v;
- int minor, nvqs = VHOST_VDPA_VQ_MAX;
+ int minor;
int r;
/* Currently, we only accept the network devices. */
@@ -903,14 +900,14 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa)
atomic_set(&v->opened, 0);
v->minor = minor;
v->vdpa = vdpa;
- v->nvqs = nvqs;
+ v->nvqs = vdpa->nvqs;
v->virtio_id = ops->get_device_id(vdpa);
device_initialize(&v->dev);
v->dev.release = vhost_vdpa_release_dev;
v->dev.parent = &vdpa->dev;
v->dev.devt = MKDEV(MAJOR(vhost_vdpa_major), minor);
- v->vqs = kmalloc_array(nvqs, sizeof(struct vhost_virtqueue),
+ v->vqs = kmalloc_array(v->nvqs, sizeof(struct vhost_virtqueue),
GFP_KERNEL);
if (!v->vqs) {
r = -ENOMEM;
diff --git a/include/linux/vdpa.h b/include/linux/vdpa.h
index 239db794357c..715a159ee1f0 100644
--- a/include/linux/vdpa.h
+++ b/include/linux/vdpa.h
@@ -39,6 +39,7 @@ struct vdpa_device {
struct device *dma_dev;
const struct vdpa_config_ops *config;
unsigned int index;
+ int nvqs;
};
/**
@@ -208,11 +209,12 @@ struct vdpa_config_ops {
struct vdpa_device *__vdpa_alloc_device(struct device *parent,
const struct vdpa_config_ops *config,
+ int nvqs,
size_t size);
-#define vdpa_alloc_device(dev_struct, member, parent, config) \
+#define vdpa_alloc_device(dev_struct, member, parent, config, nvqs) \
container_of(__vdpa_alloc_device( \
- parent, config, \
+ parent, config, nvqs, \
sizeof(dev_struct) + \
BUILD_BUG_ON_ZERO(offsetof( \
dev_struct, member))), \
--
2.27.0
next prev parent reply other threads:[~2020-07-16 7:23 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-16 7:23 [PATCH vhost next 00/10] VDPA support for Mellanox ConnectX devices Eli Cohen
2020-07-16 7:23 ` [PATCH vhost next 01/10] vhost-vdpa: support batch updating Eli Cohen
2020-07-16 7:23 ` [PATCH vhost next 02/10] vdpa_sim: use the batching API Eli Cohen
2020-07-16 7:23 ` Eli Cohen [this message]
2020-07-16 7:23 ` [PATCH vhost next 04/10] net/vdpa: Use struct for set/get vq state Eli Cohen
2020-07-16 7:23 ` [PATCH vhost next 05/10] vhost: Fix documentation Eli Cohen
2020-07-16 8:08 ` Jason Wang
2020-07-16 7:23 ` [PATCH vhost next 06/10] vdpa: Add means to communicate vq status on get_vq_state Eli Cohen
2020-07-16 8:11 ` Jason Wang
2020-07-16 8:21 ` Eli Cohen
2020-07-16 9:35 ` Jason Wang
2020-07-16 10:25 ` Eli Cohen
2020-07-20 4:13 ` Jason Wang
2020-07-16 7:23 ` [PATCH vhost next 07/10] vdpa/mlx5: Add hardware descriptive header file Eli Cohen
2020-07-16 7:23 ` [PATCH vhost next 08/10] vdpa/mlx5: Add support library for mlx5 VDPA implementation Eli Cohen
2020-07-16 10:44 ` kernel test robot
2020-07-16 7:23 ` [PATCH vhost next 09/10] vdpa/mlx5: Add shared memory registration code Eli Cohen
2020-07-16 8:13 ` Jason Wang
2020-07-16 8:28 ` Eli Cohen
2020-07-16 9:32 ` Jason Wang
2020-07-16 10:15 ` kernel test robot
2020-07-16 14:19 ` kernel test robot
2020-07-16 7:23 ` [PATCH vhost next 10/10] vdpa/mlx5: Add VDPA driver for supported mlx5 devices Eli Cohen
2020-07-16 9:14 ` Jason Wang
2020-07-16 11:54 ` Eli Cohen
2020-07-17 8:57 ` Jason Wang
2020-07-18 19:49 ` Eli Cohen
2020-07-20 4:12 ` Jason Wang
2020-07-20 5:19 ` Eli Cohen
2020-07-16 10:55 ` kernel test robot
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=20200716072327.5359-4-eli@mellanox.com \
--to=eli@mellanox.com \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maxg@mellanox.com \
--cc=mst@redhat.com \
--cc=saeedm@mellanox.com \
--cc=shahafs@mellanox.com \
--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).