Re: [PATCH RFC 07/12] vdpa_sim: move config management outside of the core

From: Jason Wang
Date: Sun Nov 15 2020 - 23:18:35 EST



On 2020/11/13 下午9:47, Stefano Garzarella wrote:
In order to simplify the code of the vdpa_sim core, we move the
config management in each device simulator.

The device must provide the size of config structure and a callback
to update this structure called during the vdpasim_set_features().


Similarly, I suggest to do this before patch 2, then there's no need for the conversion of blk device.



Signed-off-by: Stefano Garzarella <sgarzare@xxxxxxxxxx>
---
drivers/vdpa/vdpa_sim/vdpa_sim.h | 5 +++--
drivers/vdpa/vdpa_sim/vdpa_sim.c | 29 +++++-----------------------
drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 27 ++++++++++++++++----------
drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 12 ++++++++++++
4 files changed, 37 insertions(+), 36 deletions(-)

diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.h b/drivers/vdpa/vdpa_sim/vdpa_sim.h
index 76e642042eb0..f7e1fe0a88d3 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.h
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.h
@@ -10,8 +10,6 @@
#include <linux/vdpa.h>
#include <linux/vhost_iotlb.h>
#include <uapi/linux/virtio_config.h>
-#include <uapi/linux/virtio_net.h>
-#include <uapi/linux/virtio_blk.h>
#define DRV_VERSION "0.1"
#define DRV_AUTHOR "Jason Wang <jasowang@xxxxxxxxxx>"
@@ -42,8 +40,11 @@ struct vdpasim_virtqueue {
struct vdpasim_device {
u64 supported_features;
+ size_t config_size;
u32 id;
int nvqs;
+
+ void (*update_config)(struct vdpasim *vdpasim);


Let's use set_config/get_config to align with virtio/vhost.

Other looks good.

Thanks