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 145ED41D5F; Fri, 24 Feb 2023 16:13:15 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 338C742D12; Fri, 24 Feb 2023 16:12:32 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id E638842D12 for ; Fri, 24 Feb 2023 16:12:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677251550; 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=FNKdnYQyMUzLNusZYQbwqNoGk9i+a3hOl3yqKhvqFhg=; b=LR9e2hHyZF0kLTVxNPaochjqxKZdZNvTQx7Wz6LWKGDystJEApmtkNXNuPp7iIeO2qWFiJ v3myXaZnErctwGcWXWsjIevQMkxh1I+xHhzIuU3moPa1NIsyJtU+wn7Jw1Kg/jXLPlwbHc 25Ka0RlI+tXgehzBDNK5zAv/1swAzAI= 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-505-pkgUXsjBOBSBzC1IRU_2pQ-1; Fri, 24 Feb 2023 10:12:23 -0500 X-MC-Unique: pkgUXsjBOBSBzC1IRU_2pQ-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 2B93B1871D97; Fri, 24 Feb 2023 15:12:23 +0000 (UTC) Received: from dmarchan.redhat.com (unknown [10.45.224.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DC06404BEC1; Fri, 24 Feb 2023 15:12:22 +0000 (UTC) From: David Marchand To: dev@dpdk.org Cc: thomas@monjalon.net, Maxime Coquelin , Chenbo Xia Subject: [PATCH v2 11/20] net/virtio: annotate lock for guest announce Date: Fri, 24 Feb 2023 16:11:34 +0100 Message-Id: <20230224151143.3274897-12-david.marchand@redhat.com> In-Reply-To: <20230224151143.3274897-1-david.marchand@redhat.com> References: <20230224081642.2566619-1-david.marchand@redhat.com> <20230224151143.3274897-1-david.marchand@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 Expose requirements for helpers dealing with the VIRTIO_DEV_TO_HW(dev)->state_lock lock. Signed-off-by: David Marchand --- drivers/net/virtio/virtio_ethdev.c | 8 ++++---- drivers/net/virtio/virtio_ethdev.h | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 0103d95920..a3de44958c 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1149,11 +1149,11 @@ virtio_dev_pause(struct rte_eth_dev *dev) { struct virtio_hw *hw = dev->data->dev_private; - rte_spinlock_lock(&hw->state_lock); + rte_spinlock_lock(&VIRTIO_DEV_TO_HW(dev)->state_lock); if (hw->started == 0) { /* Device is just stopped. */ - rte_spinlock_unlock(&hw->state_lock); + rte_spinlock_unlock(&VIRTIO_DEV_TO_HW(dev)->state_lock); return -1; } hw->started = 0; @@ -1174,7 +1174,7 @@ virtio_dev_resume(struct rte_eth_dev *dev) struct virtio_hw *hw = dev->data->dev_private; hw->started = 1; - rte_spinlock_unlock(&hw->state_lock); + rte_spinlock_unlock(&VIRTIO_DEV_TO_HW(dev)->state_lock); } /* @@ -1217,7 +1217,7 @@ virtio_notify_peers(struct rte_eth_dev *dev) } /* If virtio port just stopped, no need to send RARP */ - if (virtio_dev_pause(dev) < 0) { + if (virtio_dev_pause(dev) != 0) { rte_pktmbuf_free(rarp_mbuf); return; } diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h index c08f382791..ece0130603 100644 --- a/drivers/net/virtio/virtio_ethdev.h +++ b/drivers/net/virtio/virtio_ethdev.h @@ -112,8 +112,11 @@ int eth_virtio_dev_init(struct rte_eth_dev *eth_dev); void virtio_interrupt_handler(void *param); -int virtio_dev_pause(struct rte_eth_dev *dev); -void virtio_dev_resume(struct rte_eth_dev *dev); +#define VIRTIO_DEV_TO_HW(dev) ((struct virtio_hw *)(dev)->data->dev_private) +int virtio_dev_pause(struct rte_eth_dev *dev) + __rte_exclusive_trylock_function(0, &VIRTIO_DEV_TO_HW(dev)->state_lock); +void virtio_dev_resume(struct rte_eth_dev *dev) + __rte_unlock_function(&VIRTIO_DEV_TO_HW(dev)->state_lock); int virtio_dev_stop(struct rte_eth_dev *dev); int virtio_dev_close(struct rte_eth_dev *dev); int virtio_inject_pkts(struct rte_eth_dev *dev, struct rte_mbuf **tx_pkts, -- 2.39.2