On Wed, Jul 19, 2023 at 9:54 AM Hawkins Jiawei <yin31...@gmail.com> wrote: > > Next patches in this series will refactor vhost_vdpa_net_load_cmd() > to iterate through the control commands shadow buffers, allowing QEMU > to send CVQ state load commands in parallel at device startup. > > Considering that QEMU always forwards the CVQ command serialized > outside of vhost_vdpa_net_load(), it is more elegant to send the > CVQ commands directly without invoking vhost_vdpa_net_load_*() helpers. > > Signed-off-by: Hawkins Jiawei <yin31...@gmail.com> > --- > net/vhost-vdpa.c | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > > diff --git a/net/vhost-vdpa.c b/net/vhost-vdpa.c > index dd71008e08..ae8f59adaa 100644 > --- a/net/vhost-vdpa.c > +++ b/net/vhost-vdpa.c > @@ -1098,12 +1098,14 @@ static NetClientInfo net_vhost_vdpa_cvq_info = { > */ > static int vhost_vdpa_net_excessive_mac_filter_cvq_add(VhostVDPAState *s, > VirtQueueElement > *elem, > - struct iovec *out) > + struct iovec *out, > + struct iovec *in) > { > struct virtio_net_ctrl_mac mac_data, *mac_ptr; > struct virtio_net_ctrl_hdr *hdr_ptr; > uint32_t cursor; > ssize_t r; > + uint8_t on = 1; > > /* parse the non-multicast MAC address entries from CVQ command */ > cursor = sizeof(*hdr_ptr); > @@ -1151,7 +1153,16 @@ static int > vhost_vdpa_net_excessive_mac_filter_cvq_add(VhostVDPAState *s, > * filter table to the vdpa device, it should send the > * VIRTIO_NET_CTRL_RX_PROMISC CVQ command to enable promiscuous mode > */ > - r = vhost_vdpa_net_load_rx_mode(s, VIRTIO_NET_CTRL_RX_PROMISC, 1); > + cursor = 0; > + hdr_ptr = out->iov_base; > + out->iov_len = sizeof(*hdr_ptr) + sizeof(on); > + assert(out->iov_len < vhost_vdpa_net_cvq_cmd_page_len()); > + > + hdr_ptr->class = VIRTIO_NET_CTRL_RX; > + hdr_ptr->cmd = VIRTIO_NET_CTRL_RX_PROMISC; > + cursor += sizeof(*hdr_ptr); > + *(uint8_t *)(out->iov_base + cursor) = on; > + r = vhost_vdpa_net_cvq_add(s, out, 1, in, 1);
Can this be done with iov_from_buf? > if (unlikely(r < 0)) { > return r; > } > @@ -1264,7 +1275,7 @@ static int > vhost_vdpa_net_handle_ctrl_avail(VhostShadowVirtqueue *svq, > * the CVQ command direclty. > */ > dev_written = vhost_vdpa_net_excessive_mac_filter_cvq_add(s, elem, > - &out); > + &out, &in); > if (unlikely(dev_written < 0)) { > goto out; > } > -- > 2.25.1 >