Hi Beilei, > -----Original Message----- > From: Xing, Beilei <beilei.x...@intel.com> > Sent: Thursday, January 7, 2021 10:42 AM > To: Xia, Chenbo <chenbo....@intel.com>; dev@dpdk.org; tho...@monjalon.net; > david.march...@redhat.com > Cc: step...@networkplumber.org; Liang, Cunming <cunming.li...@intel.com>; Lu, > Xiuchun <xiuchun...@intel.com>; Li, Miao <miao...@intel.com>; Wu, Jingjing > <jingjing...@intel.com> > Subject: RE: [dpdk-dev] [PATCH 7/9] vfio_user: add client APIs of > DMA/IRQ/region > > > > > -----Original Message----- > > From: dev <dev-boun...@dpdk.org> On Behalf Of Chenbo Xia > > Sent: Friday, December 18, 2020 3:39 PM > > To: dev@dpdk.org; tho...@monjalon.net; david.march...@redhat.com > > Cc: step...@networkplumber.org; Liang, Cunming > > <cunming.li...@intel.com>; Lu, Xiuchun <xiuchun...@intel.com>; Li, Miao > > <miao...@intel.com>; Wu, Jingjing <jingjing...@intel.com> > > Subject: [dpdk-dev] [PATCH 7/9] vfio_user: add client APIs of DMA/IRQ/region > > > > This patch introduces nine APIs > > - Device related: > > rte_vfio_user_get_dev_info and rte_vfio_user_reset > > - DMA related: > > rte_vfio_user_dma_map/unmap > > - Region related: > > rte_vfio_user_get_reg_info and rte_vfio_user_region_read/write > > - IRQ related: > > rte_vfio_user_get_irq_info and rte_vfio_user_set_irqs > > > > Signed-off-by: Chenbo Xia <chenbo....@intel.com> > > Signed-off-by: Xiuchun Lu <xiuchun...@intel.com> > > --- > > lib/librte_vfio_user/rte_vfio_user.h | 168 ++++++++++ > > lib/librte_vfio_user/version.map | 9 + > > lib/librte_vfio_user/vfio_user_client.c | 412 ++++++++++++++++++++++++ > > 3 files changed, 589 insertions(+) > > > > diff --git a/lib/librte_vfio_user/rte_vfio_user.h > > b/lib/librte_vfio_user/rte_vfio_user.h > > index b09d83e224..fe27d05992 100644 > > --- a/lib/librte_vfio_user/rte_vfio_user.h > > +++ b/lib/librte_vfio_user/rte_vfio_user.h > > @@ -229,6 +229,15 @@ int rte_vfio_user_set_irq_info(const char *sock_addr, > > > > +int rte_vfio_user_get_dev_info(int dev_id, struct vfio_device_info > > +*info) { > > + VFIO_USER_MSG msg; > > + struct vfio_user_client *dev; > > + int ret; > > + uint32_t sz = VFIO_USER_MSG_HDR_SIZE + sizeof(struct > > +vfio_device_info); > > + > > + if (!info) > > + return -EINVAL; > > + > > + dev = vfio_client_devs.cl[dev_id]; > > + if (!dev) { > > + VFIO_USER_LOG(ERR, "Failed to get device info: " > > + "wrong device ID\n"); > > + return -EINVAL; > > + } > > + > > + memset(&msg, 0, sizeof(VFIO_USER_MSG)); > > + vfio_user_client_fill_hdr(&msg, VFIO_USER_DEVICE_GET_INFO, sz); > > + > > + ret = vfio_user_client_send_recv(dev->sock.sock_fd, &msg); > > + if (ret) > > + return ret; > > + > > + if (msg.flags & VFIO_USER_ERROR) { > > + VFIO_USER_LOG(ERR, "Failed to get device info: %s\n", > > + msg.err ? strerror(msg.err) : "Unknown error"); > > + return msg.err ? -(int)msg.err : -1; > > + } > > + > > + if (vfio_user_check_msg_fdnum(&msg, 0) != 0) > > + return -1; > > + > > + memcpy(info, &msg.payload.dev_info, sizeof(*info)); > > + return ret; > > +} > > + > > Seems there's duplicate code in function get_xxx_info, double check and > refine.
OK. Will refine this. Thanks, Chenbo