qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 3/5] tools/vhost-user-i2c: Add backend driver


From: Jie Deng
Subject: Re: [PATCH 3/5] tools/vhost-user-i2c: Add backend driver
Date: Thu, 25 Mar 2021 13:09:34 +0800
User-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.7.0


On 2021/3/24 15:33, Viresh Kumar wrote:
+
+/* Definitions from virtio-i2c specifications */
+#define VHOST_USER_I2C_MAX_QUEUES       1
+
+/* Status */
+#define VIRTIO_I2C_MSG_OK               0
+#define VIRTIO_I2C_MSG_ERR              1
+
+/* The bit 0 of the @virtio_i2c_out_hdr.@flags, used to group the requests */
+#define VIRTIO_I2C_FLAGS_FAIL_NEXT      0x00000001
+
+/**
+ * struct virtio_i2c_out_hdr - the virtio I2C message OUT header
+ * @addr: the controlled device's address
+ * @padding: used to pad to full dword
+ * @flags: used for feature extensibility
+ */
+struct virtio_i2c_out_hdr {
+    uint16_t addr;
+    uint16_t padding;
+    uint32_t flags;
+} __attribute__((packed));


__le16,  __le32 ?


+
+/**
+ * struct virtio_i2c_in_hdr - the virtio I2C message IN header
+ * @status: the processing result from the backend
+ */
+struct virtio_i2c_in_hdr {
+    uint8_t status;
+} __attribute__((packed));
+


I understand these definitions can be removed once the frontend driver is merged by the Linux ?


+/* vhost-user-i2c definitions */
+
+#ifndef container_of
+#define container_of(ptr, type, member) ({                      \
+        const typeof(((type *) 0)->member) *__mptr = (ptr);     \
+        (type *) ((char *) __mptr - offsetof(type, member));})
+#endif


This seems to be a general interface.  I see there is a definition in qemu/compiler.h.

Can we reuse it ?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]