[dpdk-dev] [PATCH 03/40] net/virtio: refactor virtio-user device

David Marchand david.marchand at redhat.com
Tue Jan 5 22:16:17 CET 2021


On Sun, Dec 20, 2020 at 10:14 PM Maxime Coquelin
<maxime.coquelin at redhat.com> wrote:
>
> This patch moves the virtio_hw structure into the virtio_user_dev
> structure, with the goal of making virtio_hw bus-agnostic.
>
> Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>

Just one comment, the rest lgtm.


> diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
> index 516d0ee577..1f1f63a1a5 100644
> --- a/drivers/net/virtio/virtio_user_ethdev.c
> +++ b/drivers/net/virtio/virtio_user_ethdev.c
> @@ -26,13 +26,13 @@
>  #include "virtio_user/virtio_user_dev.h"
>  #include "virtio_user/vhost.h"
>
> -#define virtio_user_get_dev(hw) \
> -       ((struct virtio_user_dev *)(hw)->virtio_user_dev)
> +#define virtio_user_get_dev(hw) container_of(hw, struct virtio_user_dev, hw)

Since the hw parameter is expanded as both the object and the field
name too, this macro prevents us from calling anything but
virtio_user_get_dev(hw).


-- 
David Marchand



More information about the dev mailing list