From: <skoteshwar@marvell.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>,
Chenbo Xia <chenbox@nvidia.com>
Cc: <dev@dpdk.org>, Satha Rao <skoteshwar@marvell.com>
Subject: [PATCH 2/5] net/virtio-user: get link duplex and speed
Date: Mon, 7 Oct 2024 20:34:00 +0530 [thread overview]
Message-ID: <20241007150403.1680983-2-skoteshwar@marvell.com> (raw)
In-Reply-To: <20241007150403.1680983-1-skoteshwar@marvell.com>
From: Satha Rao <skoteshwar@marvell.com>
This patch extends the virtio_user_read_dev_config API to retrieve link
speed and duplex settings if the device features support
VIRTIO_NET_F_SPEED_DUPLEX.
Signed-off-by: Satha Rao <skoteshwar@marvell.com>
---
.../net/virtio/virtio_user/virtio_user_dev.c | 22 ++++++++++++++++++-
.../net/virtio/virtio_user/virtio_user_dev.h | 2 ++
drivers/net/virtio/virtio_user_ethdev.c | 6 +++++
3 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
index 2997d2bd26..91ad1312f7 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
@@ -468,6 +468,25 @@ virtio_user_dev_init_mac(struct virtio_user_dev *dev, const char *mac)
PMD_DRV_LOG(INFO, "(%s) MAC %s specified", dev->path, buf);
}
+int
+virtio_user_dev_get_speed_duplex_config(struct virtio_user_dev *dev, void *dst, size_t offset,
+ int length)
+{
+ int ret = 0;
+
+ if (!(dev->device_features & (1ULL << VIRTIO_NET_F_SPEED_DUPLEX)))
+ return -ENOTSUP;
+
+ if (!dev->ops->get_config)
+ return -ENOTSUP;
+
+ ret = dev->ops->get_config(dev, dst, offset, length);
+ if (ret)
+ PMD_DRV_LOG(ERR, "(%s) Failed to get speed/duplex config in device", dev->path);
+
+ return ret;
+}
+
static int
virtio_user_dev_init_notify(struct virtio_user_dev *dev)
{
@@ -726,7 +745,8 @@ virtio_user_free_vrings(struct virtio_user_dev *dev)
1ULL << VIRTIO_F_RING_PACKED | \
1ULL << VIRTIO_F_NOTIFICATION_DATA | \
1ULL << VIRTIO_F_ORDER_PLATFORM | \
- 1ULL << VIRTIO_NET_F_RSS)
+ 1ULL << VIRTIO_NET_F_RSS | \
+ 1ULL << VIRTIO_NET_F_SPEED_DUPLEX)
int
virtio_user_dev_init(struct virtio_user_dev *dev, char *path, uint16_t queues,
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h
index 66400b3b62..57d75d1c53 100644
--- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
+++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
@@ -87,6 +87,8 @@ int virtio_user_dev_set_mac(struct virtio_user_dev *dev);
int virtio_user_dev_get_mac(struct virtio_user_dev *dev);
int virtio_user_dev_get_rss_config(struct virtio_user_dev *dev, void *dst, size_t offset,
int length);
+int virtio_user_dev_get_speed_duplex_config(struct virtio_user_dev *dev, void *dst,
+ size_t offset, int length);
void virtio_user_dev_delayed_disconnect_handler(void *param);
int virtio_user_dev_server_reconnect(struct virtio_user_dev *dev);
extern const char * const virtio_user_backend_strings[];
diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c
index bf29f0dacd..d431b4521b 100644
--- a/drivers/net/virtio/virtio_user_ethdev.c
+++ b/drivers/net/virtio/virtio_user_ethdev.c
@@ -55,6 +55,12 @@ virtio_user_read_dev_config(struct virtio_hw *hw, size_t offset,
if (offset >= offsetof(struct virtio_net_config, rss_max_key_size))
virtio_user_dev_get_rss_config(dev, dst, offset, length);
+
+ if (offset == offsetof(struct virtio_net_config, speed))
+ virtio_user_dev_get_speed_duplex_config(dev, dst, offset, length);
+
+ if (offset == offsetof(struct virtio_net_config, duplex))
+ virtio_user_dev_get_speed_duplex_config(dev, dst, offset, length);
}
static void
--
2.25.1
next prev parent reply other threads:[~2024-10-07 15:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-07 15:03 [PATCH 1/5] interrupts: fix number of bytes read for vdev skoteshwar
2024-10-07 15:04 ` skoteshwar [this message]
2024-10-07 15:04 ` [PATCH 3/5] net/virtio: add set config callback skoteshwar
2024-10-07 15:04 ` [PATCH 4/5] net/virtio: implement update link state API skoteshwar
2024-10-07 15:04 ` [PATCH 5/5] net/virtio-user: support vDPA configuration callback skoteshwar
2024-10-09 4:01 ` [PATCH 1/5] interrupts: fix number of bytes read for vdev Stephen Hemminger
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=20241007150403.1680983-2-skoteshwar@marvell.com \
--to=skoteshwar@marvell.com \
--cc=chenbox@nvidia.com \
--cc=dev@dpdk.org \
--cc=maxime.coquelin@redhat.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).