> -----Original Message----- > From: Maxime Coquelin <maxime.coque...@redhat.com> > Sent: Wednesday, November 30, 2022 11:56 PM > To: dev@dpdk.org; Xia, Chenbo <chenbo....@intel.com>; > david.march...@redhat.com; epere...@redhat.com > Cc: Maxime Coquelin <maxime.coque...@redhat.com> > Subject: [PATCH v1 02/21] net/virtio: introduce notify callback for > control queue > > This patch introduces a notification callback for the control > virtqueue as preliminary work to add shadow control virtqueue > support. > > This new callback is required so that the shadow control queue > implemented in Virtio-user does not call the notifciation op > implemented for the driver layer. > > Signed-off-by: Maxime Coquelin <maxime.coque...@redhat.com> > --- > drivers/net/virtio/virtio_cvq.c | 4 ++-- > drivers/net/virtio/virtio_cvq.h | 4 ++++ > drivers/net/virtio/virtio_ethdev.c | 7 +++++++ > 3 files changed, 13 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/virtio/virtio_cvq.c > b/drivers/net/virtio/virtio_cvq.c > index de4299a2a7..cd25614df8 100644 > --- a/drivers/net/virtio/virtio_cvq.c > +++ b/drivers/net/virtio/virtio_cvq.c > @@ -76,7 +76,7 @@ virtio_send_command_packed(struct virtnet_ctl *cvq, > vq->hw->weak_barriers); > > virtio_wmb(vq->hw->weak_barriers); > - virtqueue_notify(vq); > + cvq->notify_queue(vq, cvq->notify_cookie); > > /* wait for used desc in virtqueue > * desc_is_used has a load-acquire or rte_io_rmb inside > @@ -155,7 +155,7 @@ virtio_send_command_split(struct virtnet_ctl *cvq, > > PMD_INIT_LOG(DEBUG, "vq->vq_queue_index = %d", vq->vq_queue_index); > > - virtqueue_notify(vq); > + cvq->notify_queue(vq, cvq->notify_cookie); > > while (virtqueue_nused(vq) == 0) > usleep(100); > diff --git a/drivers/net/virtio/virtio_cvq.h > b/drivers/net/virtio/virtio_cvq.h > index 139e813ffb..224dc81422 100644 > --- a/drivers/net/virtio/virtio_cvq.h > +++ b/drivers/net/virtio/virtio_cvq.h > @@ -7,6 +7,8 @@ > > #include <rte_ether.h> > > +struct virtqueue; > + > /** > * Control the RX mode, ie. promiscuous, allmulti, etc... > * All commands require an "out" sg entry containing a 1 byte > @@ -110,6 +112,8 @@ struct virtnet_ctl { > uint16_t port_id; /**< Device port identifier. */ > const struct rte_memzone *mz; /**< mem zone to populate CTL ring. > */ > rte_spinlock_t lock; /**< spinlock for control queue. > */ > + void (*notify_queue)(struct virtqueue *vq, void *cookie); /**< > notify ops. */ > + void *notify_cookie; /**< cookie for notify ops */ > }; > > #define VIRTIO_MAX_CTRL_DATA 2048 > diff --git a/drivers/net/virtio/virtio_ethdev.c > b/drivers/net/virtio/virtio_ethdev.c > index d553f89a0d..8db8771f4d 100644 > --- a/drivers/net/virtio/virtio_ethdev.c > +++ b/drivers/net/virtio/virtio_ethdev.c > @@ -253,6 +253,12 @@ virtio_init_vring(struct virtqueue *vq) > virtqueue_disable_intr(vq); > } > > +static void > +virtio_control_queue_notify(struct virtqueue *vq, __rte_unused void > *cookie) > +{ > + virtqueue_notify(vq); > +} > + > static int > virtio_init_queue(struct rte_eth_dev *dev, uint16_t queue_idx) > { > @@ -421,6 +427,7 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t > queue_idx) > memset(cvq->virtio_net_hdr_mz->addr, 0, rte_mem_page_size()); > > hw->cvq = cvq; > + vq->cq.notify_queue = &virtio_control_queue_notify; > } > > if (hw->use_va) > -- > 2.38.1
Reviewed-by: Chenbo Xia <chenbo....@intel.com>