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

2021-03-30 Thread Alex Bennée
Viresh Kumar writes: > On 25-03-21, 13:09, Jie Deng wrote: >> >> On 2021/3/24 15:33, Viresh Kumar wrote: > >> > +/* vhost-user-i2c definitions */ >> > + >> > +#ifndef container_of >> > +#define container_of(ptr, type, member) ({ \ >> > +const typeof(((type *) 0)

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

2021-03-26 Thread Arnd Bergmann
On Fri, Mar 26, 2021 at 7:01 AM Viresh Kumar wrote: > On 25-03-21, 17:16, Arnd Bergmann wrote: > > On Wed, Mar 24, 2021 at 8:33 AM Viresh Kumar > > wrote: > > > > > +static uint8_t vi2c_xfer(VuDev *dev, struct i2c_msg *msg) > > > +{ > > > +VuI2c *i2c = container_of(dev, VuI2c, dev.parent); >

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

2021-03-26 Thread Arnd Bergmann
On Fri, Mar 26, 2021 at 8:14 AM Viresh Kumar wrote: > On 25-03-21, 17:16, Arnd Bergmann wrote: > > On Wed, Mar 24, 2021 at 8:33 AM Viresh Kumar > > wrote: > > > > It looks like you are not handling endianness conversion here. As far as I > > can tell, the protocol requires little-endian data, b

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

2021-03-26 Thread Viresh Kumar
On 25-03-21, 17:16, Arnd Bergmann wrote: > On Wed, Mar 24, 2021 at 8:33 AM Viresh Kumar wrote: > > +static void vi2c_handle_ctrl(VuDev *dev, int qidx) > > +{ > > +VuVirtq *vq = vu_get_queue(dev, qidx); > > +struct i2c_msg msg; > > +struct virtio_i2c_out_hdr *out_hdr; > > +struct vi

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

2021-03-25 Thread Viresh Kumar
On 25-03-21, 17:16, Arnd Bergmann wrote: > On Wed, Mar 24, 2021 at 8:33 AM Viresh Kumar wrote: > > > +static uint8_t vi2c_xfer(VuDev *dev, struct i2c_msg *msg) > > +{ > > +VuI2c *i2c = container_of(dev, VuI2c, dev.parent); > > +struct i2c_rdwr_ioctl_data data; > > +VI2cAdapter *adapte

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

2021-03-25 Thread Arnd Bergmann
On Wed, Mar 24, 2021 at 8:33 AM Viresh Kumar wrote: > +static uint8_t vi2c_xfer(VuDev *dev, struct i2c_msg *msg) > +{ > +VuI2c *i2c = container_of(dev, VuI2c, dev.parent); > +struct i2c_rdwr_ioctl_data data; > +VI2cAdapter *adapter; > + > +adapter = vi2c_find_adapter(i2c, msg->add

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

2021-03-25 Thread Alex Bennée
Viresh Kumar writes: > On 25-03-21, 13:09, Jie Deng wrote: >> >> 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 >> >

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

2021-03-24 Thread Viresh Kumar
On 25-03-21, 14:17, Jie Deng wrote: > i2c->adapter_num is set here, but used in vi2c_remove_adapters. > when you goto out from while {...}, i2c->adapter_num is always 0, > May be a bug ? It certainly is, this should fix it: diff --git a/tools/vhost-user-i2c/main.c b/tools/vhost-user-i2c/main.c in

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

2021-03-24 Thread Jie Deng
On 2021/3/24 15:33, Viresh Kumar wrote: +static int vi2c_parse(VuI2c *i2c) +{ +uint16_t client_addr[MAX_I2C_VDEV]; +int32_t n_adapter = 0, n_client; +int64_t addr, bus; +const char *cp, *t; + +while (device_list) { +/* Read :[:] entries one by one */ +cp = st

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

2021-03-24 Thread Viresh Kumar
On 25-03-21, 13:09, Jie Deng wrote: > > 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

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

2021-03-24 Thread Jie Deng
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

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

2021-03-24 Thread Viresh Kumar
This adds the vhost-user backend driver to support virtio based I2C devices. vhost-user-i2c --help Signed-off-by: Viresh Kumar --- hw/virtio/vhost-user-i2c.c | 2 +- tools/meson.build| 8 + tools/vhost-user-i2c/50-qemu-i2c.json.in | 5 + tools/vhost-u