diff mbox series

[v2,1/6] vdpa: Make VhostVDPAState cvq_cmd_out_buffer control ack type

Message ID 20220824183551.197052-2-eperezma@redhat.com (mailing list archive)
State New, archived
Headers show
Series Vhost-vdpa Shadow Virtqueue multiqueue support. | expand

Commit Message

Eugenio Perez Martin Aug. 24, 2022, 6:35 p.m. UTC
This allows to simplify the code.

Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
---
 net/vhost-vdpa.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Jason Wang Aug. 25, 2022, 3:07 a.m. UTC | #1
On Thu, Aug 25, 2022 at 2:36 AM Eugenio Pérez <eperezma@redhat.com> wrote:
>
> This allows to simplify the code.
>
> Signed-off-by: Eugenio Pérez <eperezma@redhat.com>
> ---
>  net/vhost-vdpa.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
> index 6ce68fcd3f..468e460ac2 100644
> --- a/net/vhost-vdpa.c
> +++ b/net/vhost-vdpa.c
> @@ -35,7 +35,9 @@ typedef struct VhostVDPAState {
>      VHostNetState *vhost_net;
>
>      /* Control commands shadow buffers */
> -    void *cvq_cmd_out_buffer, *cvq_cmd_in_buffer;
> +    void *cvq_cmd_out_buffer;
> +    virtio_net_ctrl_ack *cvq_cmd_in_buffer;

Nit, let's simply rename this to 'status'.

Thanks

> +
>      bool started;
>  } VhostVDPAState;
>
> @@ -396,7 +398,7 @@ static int vhost_vdpa_net_load(NetClientState *nc)
>              return dev_written;
>          }
>
> -        return *((virtio_net_ctrl_ack *)s->cvq_cmd_in_buffer) != VIRTIO_NET_OK;
> +        return *s->cvq_cmd_in_buffer != VIRTIO_NET_OK;
>      }
>
>      return 0;
> @@ -491,8 +493,7 @@ static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq,
>          goto out;
>      }
>
> -    memcpy(&status, s->cvq_cmd_in_buffer, sizeof(status));
> -    if (status != VIRTIO_NET_OK) {
> +    if (*s->cvq_cmd_in_buffer != VIRTIO_NET_OK) {
>          return VIRTIO_NET_ERR;
>      }
>
> --
> 2.31.1
>
diff mbox series

Patch

diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c
index 6ce68fcd3f..468e460ac2 100644
--- a/net/vhost-vdpa.c
+++ b/net/vhost-vdpa.c
@@ -35,7 +35,9 @@  typedef struct VhostVDPAState {
     VHostNetState *vhost_net;
 
     /* Control commands shadow buffers */
-    void *cvq_cmd_out_buffer, *cvq_cmd_in_buffer;
+    void *cvq_cmd_out_buffer;
+    virtio_net_ctrl_ack *cvq_cmd_in_buffer;
+
     bool started;
 } VhostVDPAState;
 
@@ -396,7 +398,7 @@  static int vhost_vdpa_net_load(NetClientState *nc)
             return dev_written;
         }
 
-        return *((virtio_net_ctrl_ack *)s->cvq_cmd_in_buffer) != VIRTIO_NET_OK;
+        return *s->cvq_cmd_in_buffer != VIRTIO_NET_OK;
     }
 
     return 0;
@@ -491,8 +493,7 @@  static int vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq,
         goto out;
     }
 
-    memcpy(&status, s->cvq_cmd_in_buffer, sizeof(status));
-    if (status != VIRTIO_NET_OK) {
+    if (*s->cvq_cmd_in_buffer != VIRTIO_NET_OK) {
         return VIRTIO_NET_ERR;
     }