Re: [dpdk-dev] [PATCH 03/40] net/virtio: refactor virtio-user device
From: Maxime Coquelin <hidden>
Date: 2021-01-14 09:26:53
On 1/5/21 10:16 PM, David Marchand wrote:
On Sun, Dec 20, 2020 at 10:14 PM Maxime Coquelin [off-list ref] wrote:quoted
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 <redacted>Just one comment, the rest lgtm.quoted
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).
Indeed! I propose to change the parameter to hwp (hw pointer). Thanks, Maxime