From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: passt.top; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: passt.top; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=CqaDx8N5; dkim-atps=neutral Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by passt.top (Postfix) with ESMTPS id C1EED5A0274 for ; Thu, 19 Dec 2024 14:44:02 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1734615841; 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=K/C2FaELYB194faW67ns/KESvof0/3ViY5ttVGEPsxw=; b=CqaDx8N5TLRjbZ0drGMplZRLtszxhTSFVr/ZSSMYL+XTrYd0ZGgVz+zUSLl9djfzFBI1Km wG/6yHMceYwdD78G50add/WuyAg6pTXwkcluypCjaCxRKCYwo3BZWAlXD62FYKg0MAqhJl kC+UhMBG/1pnoNtG4ElzrBNRbRMB4hA= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-591-4ca1wxM5OjG4JUUIXwfCbw-1; Thu, 19 Dec 2024 06:14:10 -0500 X-MC-Unique: 4ca1wxM5OjG4JUUIXwfCbw-1 X-Mimecast-MFC-AGG-ID: 4ca1wxM5OjG4JUUIXwfCbw Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 6FDE919560BE for ; Thu, 19 Dec 2024 11:14:09 +0000 (UTC) Received: from lenovo-t14s.redhat.com (unknown [10.39.193.37]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 621C819560A2; Thu, 19 Dec 2024 11:14:08 +0000 (UTC) From: Laurent Vivier To: passt-dev@passt.top Subject: [PATCH 4/9] vhost-user: Pass vu_dev to more virtio functions Date: Thu, 19 Dec 2024 12:13:55 +0100 Message-ID: <20241219111400.2352110-5-lvivier@redhat.com> In-Reply-To: <20241219111400.2352110-1-lvivier@redhat.com> References: <20241219111400.2352110-1-lvivier@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: cF59eJwV_1-IH2hFOKIGd3nTzG3ihpR3DkE3koQBr_E_1734606849 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true Message-ID-Hash: MA2CCZMQW3E7WEYTYPJHBFZGZOT5ZRNG X-Message-ID-Hash: MA2CCZMQW3E7WEYTYPJHBFZGZOT5ZRNG X-MailFrom: lvivier@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Laurent Vivier X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: vu_dev will be needed to log page update. Add the parameter to: vring_used_write() vu_queue_fill_by_index() vu_queue_fill() vring_used_idx_set() vu_queue_flush() The new parameter is unused for now. Signed-off-by: Laurent Vivier --- virtio.c | 32 ++++++++++++++++++++++---------- virtio.h | 10 ++++++---- vu_common.c | 8 ++++---- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/virtio.c b/virtio.c index 625bac385f0c..52d5a4d4be52 100644 --- a/virtio.c +++ b/virtio.c @@ -580,28 +580,34 @@ bool vu_queue_rewind(struct vu_virtq *vq, unsigned int num) /** * vring_used_write() - Write an entry in the used ring + * @dev: Vhost-user device * @vq: Virtqueue * @uelem: Entry to write * @i: Index of the entry in the used ring */ -static inline void vring_used_write(struct vu_virtq *vq, +static inline void vring_used_write(const struct vu_dev *vdev, + struct vu_virtq *vq, const struct vring_used_elem *uelem, int i) { struct vring_used *used = vq->vring.used; used->ring[i] = *uelem; + (void)vdev; } + /** * vu_queue_fill_by_index() - Update information of a descriptor ring entry * in the used ring + * @dev: Vhost-user device * @vq: Virtqueue * @index: Descriptor ring index * @len: Size of the element * @idx: Used ring entry index */ -void vu_queue_fill_by_index(struct vu_virtq *vq, unsigned int index, - unsigned int len, unsigned int idx) +void vu_queue_fill_by_index(const struct vu_dev *vdev, struct vu_virtq *vq, + unsigned int index, unsigned int len, + unsigned int idx) { struct vring_used_elem uelem; @@ -612,7 +618,7 @@ void vu_queue_fill_by_index(struct vu_virtq *vq, unsigned int index, uelem.id = htole32(index); uelem.len = htole32(len); - vring_used_write(vq, &uelem, idx); + vring_used_write(vdev, vq, &uelem, idx); } /** @@ -623,30 +629,36 @@ void vu_queue_fill_by_index(struct vu_virtq *vq, unsigned int index, * @len: Size of the element * @idx: Used ring entry index */ -void vu_queue_fill(struct vu_virtq *vq, const struct vu_virtq_element *elem, - unsigned int len, unsigned int idx) +void vu_queue_fill(const struct vu_dev *vdev, struct vu_virtq *vq, + const struct vu_virtq_element *elem, unsigned int len, + unsigned int idx) { - vu_queue_fill_by_index(vq, elem->index, len, idx); + vu_queue_fill_by_index(vdev, vq, elem->index, len, idx); } /** * vring_used_idx_set() - Set the descriptor ring current index + * @dev: Vhost-user device * @vq: Virtqueue * @val: Value to set in the index */ -static inline void vring_used_idx_set(struct vu_virtq *vq, uint16_t val) +static inline void vring_used_idx_set(const struct vu_dev *vdev, + struct vu_virtq *vq, uint16_t val) { vq->vring.used->idx = htole16(val); + (void)vdev; vq->used_idx = val; } /** * vu_queue_flush() - Flush the virtqueue + * @dev: Vhost-user device * @vq: Virtqueue * @count: Number of entry to flush */ -void vu_queue_flush(struct vu_virtq *vq, unsigned int count) +void vu_queue_flush(const struct vu_dev *vdev, struct vu_virtq *vq, + unsigned int count) { uint16_t old, new; @@ -658,7 +670,7 @@ void vu_queue_flush(struct vu_virtq *vq, unsigned int count) old = vq->used_idx; new = old + count; - vring_used_idx_set(vq, new); + vring_used_idx_set(vdev, vq, new); vq->inuse -= count; if ((uint16_t)(new - vq->signalled_used) < (uint16_t)(new - old)) vq->signalled_used_valid = false; diff --git a/virtio.h b/virtio.h index 3b0df343d6b6..d95bb07bb913 100644 --- a/virtio.h +++ b/virtio.h @@ -177,10 +177,12 @@ int vu_queue_pop(const struct vu_dev *dev, struct vu_virtq *vq, void vu_queue_detach_element(struct vu_virtq *vq); void vu_queue_unpop(struct vu_virtq *vq); bool vu_queue_rewind(struct vu_virtq *vq, unsigned int num); -void vu_queue_fill_by_index(struct vu_virtq *vq, unsigned int index, - unsigned int len, unsigned int idx); -void vu_queue_fill(struct vu_virtq *vq, +void vu_queue_fill_by_index(const struct vu_dev *vdev, struct vu_virtq *vq, + unsigned int index, unsigned int len, + unsigned int idx); +void vu_queue_fill(const struct vu_dev *vdev, struct vu_virtq *vq, const struct vu_virtq_element *elem, unsigned int len, unsigned int idx); -void vu_queue_flush(struct vu_virtq *vq, unsigned int count); +void vu_queue_flush(const struct vu_dev *vdev, struct vu_virtq *vq, + unsigned int count); #endif /* VIRTIO_H */ diff --git a/vu_common.c b/vu_common.c index 6d365bea5fe2..16e7e76a07f3 100644 --- a/vu_common.c +++ b/vu_common.c @@ -140,9 +140,9 @@ void vu_flush(const struct vu_dev *vdev, struct vu_virtq *vq, int i; for (i = 0; i < elem_cnt; i++) - vu_queue_fill(vq, &elem[i], elem[i].in_sg[0].iov_len, i); + vu_queue_fill(vdev, vq, &elem[i], elem[i].in_sg[0].iov_len, i); - vu_queue_flush(vq, elem_cnt); + vu_queue_flush(vdev, vq, elem_cnt); vu_queue_notify(vdev, vq); } @@ -194,8 +194,8 @@ static void vu_handle_tx(struct vu_dev *vdev, int index, int i; for (i = 0; i < count; i++) - vu_queue_fill(vq, &elem[i], 0, i); - vu_queue_flush(vq, count); + vu_queue_fill(vdev, vq, &elem[i], 0, i); + vu_queue_flush(vdev, vq, count); vu_queue_notify(vdev, vq); } } -- 2.47.1