From patchwork Wed Jul 15 17:18:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adrian Moreno X-Patchwork-Id: 74126 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id B55A2A0542; Wed, 15 Jul 2020 19:18:50 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 67FD31B1D5; Wed, 15 Jul 2020 19:18:48 +0200 (CEST) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id 9D089199BC for ; Wed, 15 Jul 2020 19:18:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594833525; 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=6U9fw7qapihYcyowM1zHNzqfGaJnMJXbpumVq6fYE+M=; b=Te2DmIjjhS8MRPTTBa9rv1T/trxGa2IKH9sI0pXFkIIvhTBTX1maC2u2LEg8tnd/wdIblR MY7xUweFS91IE+WPqSbx7PfFrDsi84ZO9u6pQyN7CMYhHYtrPuUoS0aMGhg9Ys9xwCQOL9 1lGnpffCaFsGjFaq8/HuJP3xK1X6W2E= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-302-fr6JT-d0Nf-C3X5qDPK-CA-1; Wed, 15 Jul 2020 13:18:42 -0400 X-MC-Unique: fr6JT-d0Nf-C3X5qDPK-CA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EFB8880BCC7; Wed, 15 Jul 2020 17:18:40 +0000 (UTC) Received: from amorenoz.users.ipa.redhat.com (ovpn-113-28.ams2.redhat.com [10.36.113.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6689260C05; Wed, 15 Jul 2020 17:18:39 +0000 (UTC) From: Adrian Moreno To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, zhihong.wang@intel.com, amorenoz@redhat.com, chenbo.xia@intel.com Date: Wed, 15 Jul 2020 19:18:24 +0200 Message-Id: <20200715171828.95887-2-amorenoz@redhat.com> In-Reply-To: <20200715171828.95887-1-amorenoz@redhat.com> References: <20200715171828.95887-1-amorenoz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Subject: [dpdk-dev] [PATCH 1/5] net/virtio: split virtio-net and virtio status X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Currently, the same field is being used to store both the generic virtio device status and the virtio-net-specific status. This can become problematic since they have different sets of status bits that may collide (e.g: VIRTIO_CONFIG_STATUS_ACK and VIRTIO_NET_S_LINK_UP). Split them in different fields. Signed-off-by: Adrian Moreno --- drivers/net/virtio/virtio_user/virtio_user_dev.h | 5 ++++- drivers/net/virtio/virtio_user_ethdev.c | 11 ++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h index 56e638f8a..10b274d19 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h @@ -43,7 +43,10 @@ struct virtio_user_dev { uint64_t protocol_features; /* negotiated protocol features * (Vhost-user only) */ - uint8_t status; + + uint8_t virtio_net_status; /* virtio-net device status */ + uint8_t status; /* virtio device status */ + uint16_t port_id; uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; char path[PATH_MAX]; diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index e51425c4f..5b06d8e89 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -205,7 +205,8 @@ virtio_user_read_dev_config(struct virtio_hw *hw, size_t offset, } r = recv(dev->vhostfd, buf, 128, MSG_PEEK); if (r == 0 || (r < 0 && errno != EAGAIN)) { - dev->status &= (~VIRTIO_NET_S_LINK_UP); + dev->virtio_net_status &= + (~VIRTIO_NET_S_LINK_UP); PMD_DRV_LOG(ERR, "virtio-user port %u is down", hw->port_id); @@ -217,7 +218,7 @@ virtio_user_read_dev_config(struct virtio_hw *hw, size_t offset, virtio_user_delayed_handler, (void *)hw); } else { - dev->status |= VIRTIO_NET_S_LINK_UP; + dev->virtio_net_status |= VIRTIO_NET_S_LINK_UP; } if (fcntl(dev->vhostfd, F_SETFL, flags & ~O_NONBLOCK) == -1) { @@ -225,12 +226,12 @@ virtio_user_read_dev_config(struct virtio_hw *hw, size_t offset, return; } } else if (dev->is_server) { - dev->status &= (~VIRTIO_NET_S_LINK_UP); + dev->virtio_net_status &= (~VIRTIO_NET_S_LINK_UP); if (virtio_user_server_reconnect(dev) >= 0) - dev->status |= VIRTIO_NET_S_LINK_UP; + dev->virtio_net_status |= VIRTIO_NET_S_LINK_UP; } - *(uint16_t *)dst = dev->status; + *(uint16_t *)dst = dev->virtio_net_status; } if (offset == offsetof(struct virtio_net_config, max_virtqueue_pairs))