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 DCE2645AD6; Mon, 7 Oct 2024 17:04:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 80F20427C4; Mon, 7 Oct 2024 17:04:29 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 7B450427BF for ; Mon, 7 Oct 2024 17:04:26 +0200 (CEST) Received: from pps.filterd (m0431383.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4979Q8PQ013834; Mon, 7 Oct 2024 08:04:25 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=3 qjMV0c9PE3Hsa59Uy1AAR9aVixn37IxJTaBmOwnMvQ=; b=dYAZRMw7dHLSA5ZCo 0YSKtwH4JotJggltrAKw9EgK9u42lwGhZ0dhHDtctp6x7D12+KVdGvp9daikg4q+ ZnDUJewOGf5X3U6aEa5yKydznktccUwsWiEvq9G3PfQj2lVgK0rFB6m7fJ/Qpi61 mO7yObOEoRSanY8kjF8LoSIKwZUjj4BwOlUTc4lFvtEGszkucARFL8RX9nbt4SD0 LkH4tEHznbUYXHp5TQBfC1iU5zR7AktBjB5pQp4KpuXFB62yt2e7aZI2x3fMyqYN oJ8IAbeViRFGB9yHqQiClZd2R4FH26kt1WJgd5tbwat5aoFXuLqHlH8j87CJERAv U+ftA== Received: from dc6wp-exch02.marvell.com ([4.21.29.225]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 424d0q0mf9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 07 Oct 2024 08:04:25 -0700 (PDT) Received: from DC6WP-EXCH02.marvell.com (10.76.176.209) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Mon, 7 Oct 2024 08:04:24 -0700 Received: from maili.marvell.com (10.69.176.80) by DC6WP-EXCH02.marvell.com (10.76.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Mon, 7 Oct 2024 08:04:24 -0700 Received: from localhost.localdomain (unknown [10.28.36.14]) by maili.marvell.com (Postfix) with ESMTP id 3EA2D3F705B; Mon, 7 Oct 2024 08:04:23 -0700 (PDT) From: To: Maxime Coquelin , Chenbo Xia CC: , Satha Rao Subject: [PATCH 2/5] net/virtio-user: get link duplex and speed Date: Mon, 7 Oct 2024 20:34:00 +0530 Message-ID: <20241007150403.1680983-2-skoteshwar@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241007150403.1680983-1-skoteshwar@marvell.com> References: <20241007150403.1680983-1-skoteshwar@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 86jpUFPAr2UVycDw85tScoR5q3QzaVYL X-Proofpoint-ORIG-GUID: 86jpUFPAr2UVycDw85tScoR5q3QzaVYL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.687,Hydra:6.0.235,FMLib:17.0.607.475 definitions=2020-10-13_15,2020-10-13_02,2020-04-07_01 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 From: Satha Rao 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 --- .../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