Re: [PATCH RFC 10/12] vdpa_sim: split vdpasim_virtqueue's iov field in riov and wiov

2020-11-20 Thread Stefano Garzarella

On Tue, Nov 17, 2020 at 11:27:03AM +, Stefan Hajnoczi wrote:

On Fri, Nov 13, 2020 at 02:47:10PM +0100, Stefano Garzarella wrote:

vringh_getdesc_iotlb() manages 2 iovs for writable and readable
descriptors. This is very useful for the block device, where for
each request we have both types of descriptor.

Let's split the vdpasim_virtqueue's iov field in riov and wiov
to use them with vringh_getdesc_iotlb().


Is riov/wiov naming common? VIRTIO uses "in" (device-to-driver) and
"out" (driver-to-device). Using VIRTIO terminology might be clearer.


I followed the vringh_getdesc_iotlb() attribute names, but I agree that 
"in" and "out" would be better. I lost multiple times with read/write...


I'll fix!

Thanks,
Stefano



Re: [PATCH RFC 10/12] vdpa_sim: split vdpasim_virtqueue's iov field in riov and wiov

2020-11-17 Thread Stefan Hajnoczi
On Fri, Nov 13, 2020 at 02:47:10PM +0100, Stefano Garzarella wrote:
> vringh_getdesc_iotlb() manages 2 iovs for writable and readable
> descriptors. This is very useful for the block device, where for
> each request we have both types of descriptor.
> 
> Let's split the vdpasim_virtqueue's iov field in riov and wiov
> to use them with vringh_getdesc_iotlb().

Is riov/wiov naming common? VIRTIO uses "in" (device-to-driver) and
"out" (driver-to-device). Using VIRTIO terminology might be clearer.

Stefan


signature.asc
Description: PGP signature


Re: [PATCH RFC 10/12] vdpa_sim: split vdpasim_virtqueue's iov field in riov and wiov

2020-11-15 Thread Jason Wang



On 2020/11/13 下午9:47, Stefano Garzarella wrote:

vringh_getdesc_iotlb() manages 2 iovs for writable and readable
descriptors. This is very useful for the block device, where for
each request we have both types of descriptor.

Let's split the vdpasim_virtqueue's iov field in riov and wiov
to use them with vringh_getdesc_iotlb().

Signed-off-by: Stefano Garzarella 



Acked-by: Jason Wang 



---
  drivers/vdpa/vdpa_sim/vdpa_sim.h | 3 ++-
  drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 6 +++---
  drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 8 
  3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.h b/drivers/vdpa/vdpa_sim/vdpa_sim.h
index cc21e07aa2f7..0d4629675e4b 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.h
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.h
@@ -27,7 +27,8 @@ struct vdpasim;
  
  struct vdpasim_virtqueue {

struct vringh vring;
-   struct vringh_kiov iov;
+   struct vringh_kiov riov;
+   struct vringh_kiov wiov;
unsigned short head;
bool ready;
u64 desc_addr;
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c 
b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
index 122a3c039507..8e41b3ab98d5 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
@@ -41,13 +41,13 @@ static void vdpasim_blk_work(struct work_struct *work)
if (!vq->ready)
continue;
  
-		while (vringh_getdesc_iotlb(>vring, >iov, >iov,

+   while (vringh_getdesc_iotlb(>vring, >riov, >wiov,
>head, GFP_ATOMIC) > 0) {
  
  			int write;
  
-			vq->iov.i = vq->iov.used - 1;

-   write = vringh_iov_push_iotlb(>vring, >iov, 
, 1);
+   vq->wiov.i = vq->wiov.used - 1;
+   write = vringh_iov_push_iotlb(>vring, >wiov, 
, 1);
if (write <= 0)
break;
  
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c

index d0a1403f64b2..783b1e85b09c 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
@@ -47,12 +47,12 @@ static void vdpasim_net_work(struct work_struct *work)
  
  	while (true) {

total_write = 0;
-   err = vringh_getdesc_iotlb(>vring, >iov, NULL,
+   err = vringh_getdesc_iotlb(>vring, >riov, NULL,
   >head, GFP_ATOMIC);
if (err <= 0)
break;
  
-		err = vringh_getdesc_iotlb(>vring, NULL, >iov,

+   err = vringh_getdesc_iotlb(>vring, NULL, >wiov,
   >head, GFP_ATOMIC);
if (err <= 0) {
vringh_complete_iotlb(>vring, txq->head, 0);
@@ -60,13 +60,13 @@ static void vdpasim_net_work(struct work_struct *work)
}
  
  		while (true) {

-   read = vringh_iov_pull_iotlb(>vring, >iov,
+   read = vringh_iov_pull_iotlb(>vring, >riov,
 vdpasim->buffer,
 PAGE_SIZE);
if (read <= 0)
break;
  
-			write = vringh_iov_push_iotlb(>vring, >iov,

+   write = vringh_iov_push_iotlb(>vring, >wiov,
  vdpasim->buffer, read);
if (write <= 0)
break;




[PATCH RFC 10/12] vdpa_sim: split vdpasim_virtqueue's iov field in riov and wiov

2020-11-13 Thread Stefano Garzarella
vringh_getdesc_iotlb() manages 2 iovs for writable and readable
descriptors. This is very useful for the block device, where for
each request we have both types of descriptor.

Let's split the vdpasim_virtqueue's iov field in riov and wiov
to use them with vringh_getdesc_iotlb().

Signed-off-by: Stefano Garzarella 
---
 drivers/vdpa/vdpa_sim/vdpa_sim.h | 3 ++-
 drivers/vdpa/vdpa_sim/vdpa_sim_blk.c | 6 +++---
 drivers/vdpa/vdpa_sim/vdpa_sim_net.c | 8 
 3 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim.h b/drivers/vdpa/vdpa_sim/vdpa_sim.h
index cc21e07aa2f7..0d4629675e4b 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim.h
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim.h
@@ -27,7 +27,8 @@ struct vdpasim;
 
 struct vdpasim_virtqueue {
struct vringh vring;
-   struct vringh_kiov iov;
+   struct vringh_kiov riov;
+   struct vringh_kiov wiov;
unsigned short head;
bool ready;
u64 desc_addr;
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c 
b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
index 122a3c039507..8e41b3ab98d5 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim_blk.c
@@ -41,13 +41,13 @@ static void vdpasim_blk_work(struct work_struct *work)
if (!vq->ready)
continue;
 
-   while (vringh_getdesc_iotlb(>vring, >iov, >iov,
+   while (vringh_getdesc_iotlb(>vring, >riov, >wiov,
>head, GFP_ATOMIC) > 0) {
 
int write;
 
-   vq->iov.i = vq->iov.used - 1;
-   write = vringh_iov_push_iotlb(>vring, >iov, 
, 1);
+   vq->wiov.i = vq->wiov.used - 1;
+   write = vringh_iov_push_iotlb(>vring, >wiov, 
, 1);
if (write <= 0)
break;
 
diff --git a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c 
b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
index d0a1403f64b2..783b1e85b09c 100644
--- a/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
+++ b/drivers/vdpa/vdpa_sim/vdpa_sim_net.c
@@ -47,12 +47,12 @@ static void vdpasim_net_work(struct work_struct *work)
 
while (true) {
total_write = 0;
-   err = vringh_getdesc_iotlb(>vring, >iov, NULL,
+   err = vringh_getdesc_iotlb(>vring, >riov, NULL,
   >head, GFP_ATOMIC);
if (err <= 0)
break;
 
-   err = vringh_getdesc_iotlb(>vring, NULL, >iov,
+   err = vringh_getdesc_iotlb(>vring, NULL, >wiov,
   >head, GFP_ATOMIC);
if (err <= 0) {
vringh_complete_iotlb(>vring, txq->head, 0);
@@ -60,13 +60,13 @@ static void vdpasim_net_work(struct work_struct *work)
}
 
while (true) {
-   read = vringh_iov_pull_iotlb(>vring, >iov,
+   read = vringh_iov_pull_iotlb(>vring, >riov,
 vdpasim->buffer,
 PAGE_SIZE);
if (read <= 0)
break;
 
-   write = vringh_iov_push_iotlb(>vring, >iov,
+   write = vringh_iov_push_iotlb(>vring, >wiov,
  vdpasim->buffer, read);
if (write <= 0)
break;
-- 
2.26.2