From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 08FD1A00C2; Wed, 30 Nov 2022 16:56:57 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C95CD410D1; Wed, 30 Nov 2022 16:56:55 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id EC7AD410D1 for ; Wed, 30 Nov 2022 16:56:53 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669823813; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GYBjD4B3QxKiFMGuZKfC1lW+Vxw9mK6Xfo9mvw8PNR8=; b=Noy/3zOaVvIvKaUluICxy69dwGDy2b5T/eWVKzpXWKOSVz/qsdNPrY9zPEAq15U3TYl0Ct maYzFDrsJZOviyv9u5EVAa5aXy5b9Pu71//lAb9C2QnRFghLT0VRmeE8h76tphYOINZpXJ rfSIr9OVRR6UT0uUt3FHL+5UpRSoRuE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-674-hkrJsffSNN6jk36bcnZuvQ-1; Wed, 30 Nov 2022 10:56:51 -0500 X-MC-Unique: hkrJsffSNN6jk36bcnZuvQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 865E1811E7A; Wed, 30 Nov 2022 15:56:51 +0000 (UTC) Received: from max-t490s.redhat.com (unknown [10.39.208.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64AE140C83ED; Wed, 30 Nov 2022 15:56:50 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, chenbo.xia@intel.com, david.marchand@redhat.com, eperezma@redhat.com Cc: Maxime Coquelin Subject: [PATCH v1 02/21] net/virtio: introduce notify callback for control queue Date: Wed, 30 Nov 2022 16:56:20 +0100 Message-Id: <20221130155639.150553-3-maxime.coquelin@redhat.com> In-Reply-To: <20221130155639.150553-1-maxime.coquelin@redhat.com> References: <20221130155639.150553-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- 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 +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