From: Adrian Moreno <amorenoz@redhat.com>
To: dev@dpdk.org
Cc: maxime.coquelin@redhat.com, zhihong.wang@intel.com,
amorenoz@redhat.com, chenbo.xia@intel.com
Subject: [dpdk-dev] [PATCH 1/5] net/virtio: split virtio-net and virtio status
Date: Wed, 15 Jul 2020 19:18:24 +0200 [thread overview]
Message-ID: <20200715171828.95887-2-amorenoz@redhat.com> (raw)
In-Reply-To: <20200715171828.95887-1-amorenoz@redhat.com>
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 <amorenoz@redhat.com>
---
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))
--
2.26.2
next prev parent reply other threads:[~2020-07-15 17:18 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-15 17:18 [dpdk-dev] [PATCH 0/5] Add support for GET/SET_STATUS on virtio-user pmd Adrian Moreno
2020-07-15 17:18 ` Adrian Moreno [this message]
2020-07-15 17:18 ` [dpdk-dev] [PATCH 2/5] net/virtio: add DEVICE_NEEDS_RESET status bit Adrian Moreno
2020-07-16 2:26 ` Xia, Chenbo
2020-07-16 7:34 ` Adrian Moreno
2020-07-16 8:14 ` Xia, Chenbo
2020-07-15 17:18 ` [dpdk-dev] [PATCH 3/5] net/virtio: add VIRTIO_SET_STATUS support to Virtio-user Adrian Moreno
2020-07-16 3:15 ` Xia, Chenbo
2020-07-16 7:43 ` Adrian Moreno
2020-07-16 8:58 ` Xia, Chenbo
2020-07-16 9:51 ` Adrian Moreno
2020-07-16 11:18 ` Xia, Chenbo
2020-07-15 17:18 ` [dpdk-dev] [PATCH 4/5] net/virtio: add GET_STATUS support to virtio-user Adrian Moreno
2020-07-16 3:31 ` Xia, Chenbo
2020-07-16 7:53 ` Adrian Moreno
2020-07-16 8:18 ` David Marchand
2020-07-16 8:28 ` Adrian Moreno
2020-07-15 17:18 ` [dpdk-dev] [PATCH 5/5] net/virtio: enable feature checking on virtio-user Adrian Moreno
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200715171828.95887-2-amorenoz@redhat.com \
--to=amorenoz@redhat.com \
--cc=chenbo.xia@intel.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.com \
--cc=zhihong.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).