From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2D2DFA0588; Thu, 16 Apr 2020 14:44:36 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 360061DC88; Thu, 16 Apr 2020 14:43:26 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 406A71DC49 for ; Thu, 16 Apr 2020 14:43:22 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200416124322euoutp0199a3320324ef4be65450e1d599f03255~GTWIDr7iH0589505895euoutp01X for ; Thu, 16 Apr 2020 12:43:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200416124322euoutp0199a3320324ef4be65450e1d599f03255~GTWIDr7iH0589505895euoutp01X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1587041002; bh=iR2nubcRfZZfuamrSwGwMbAQtyb7R+YhVTXAXvQjG0U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=G9D1vzPuzB9DO99w9tXHtPoNAZo6xF2T3FJhOpEoN5h4N4RF1HV9H1H5LJiciuQMn b5m/bg+5NU9yQSxQFIsNdE4h3MbZj9hzMYvwqMr46BmxuC/Xh71t6jp/WAyxLXk5fx OAj2u2MnmLXKhMhSIwFTLPtC9Z8FFDd48LX0PNT0= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200416124321eucas1p1f24f34c2747091ceb29e425ad6143964~GTWHze-2C1957019570eucas1p1m; Thu, 16 Apr 2020 12:43:21 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 9E.B2.60679.9E2589E5; Thu, 16 Apr 2020 13:43:21 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200416124321eucas1p2768f2846666ffad04efcadd871859cf9~GTWHgB3mt0431804318eucas1p2M; Thu, 16 Apr 2020 12:43:21 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200416124321eusmtrp227169b20d56344e44120af2d3973e9a8~GTWHfczOP1274212742eusmtrp2A; Thu, 16 Apr 2020 12:43:21 +0000 (GMT) X-AuditID: cbfec7f4-0cbff7000001ed07-9c-5e9852e9f1c3 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id 9A.BA.08375.9E2589E5; Thu, 16 Apr 2020 13:43:21 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200416124320eusmtip26616a27cd80fec57b08e718391144de1~GTWG1FCgo0292802928eusmtip2Z; Thu, 16 Apr 2020 12:43:20 +0000 (GMT) From: Ivan Dyukov To: dev@dpdk.org, maxime.coquelin@redhat.com, i.dyukov@samsung.com, v.kuramshin@samsung.com, amorenoz@redhat.com, zhihong.wang@intel.com, xiaolong.ye@intel.com, mb@smartsharesystems.com Date: Thu, 16 Apr 2020 15:42:58 +0300 Message-Id: <20200416124258.15549-8-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416124258.15549-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMIsWRmVeSWpSXmKPExsWy7djP87ovg2bEGdy6rGPRuuMBi8W7T9uZ LGZdamK3ONa5h8Wi79dVRovTNzezW/x5Y2qx+eIkJgcOj18LlrJ6LN7zksnj/b6rbB59W1Yx epx61M0cwBrFZZOSmpNZllqkb5fA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S/y51sUGUfOZUeLF+zPsIAk2AQ2J0x3zmEASIgLHGSV6Z/1nAkkIC3hKzHq3nxFk EIuAqsTvbleQMK+ApcTxh4dYIIbKS6zecABsAaeAlcTd7lesILaQQIbEwkuPWSYw8i5gZFjF KJJaWpybnltsqFecmFtcmpeul5yfu4kRGKTbjv3cvIPx0sbgQ4wCHIxKPLwJ9jPihFgTy4or cw8xSnAwK4nw8pkChXhTEiurUovy44tKc1KLDzGaAt00kVlKNDkfGEF5JfGGpobmFpaG5sbm xmYWSuK8HQIHY4QE0hNLUrNTUwtSi2D6mDg4pRoY5S7eksg722LM3Ch5XpRtIv8tv/0HQv5r OXnOX+Q6kVdFUJ0/OmbzPvFtm0o9Njl+djbdr/BGtfjJ1unnazyLNrgpcEcERBRffSRaVnZ7 msyh5Ce8N2X0Z8xYwHfv0nQ17h6HhDOrtrw8p8/YtL7nTrHYd4Y40UxRSxld6VsfyvUOZu8O vCChxFKckWioxVxUnAgAo4Cm22gCAAA= X-CMS-MailID: 20200416124321eucas1p2768f2846666ffad04efcadd871859cf9 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200416124321eucas1p2768f2846666ffad04efcadd871859cf9 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200416124321eucas1p2768f2846666ffad04efcadd871859cf9 References: <20191212085012.9170-1-i.dyukov@samsung.com> <20200416124258.15549-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v12 7/7] net/virtio: Support of VIRTIO_NET_F_SPEED_DUPLEX 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" This patch adds a support of VIRTIO_NET_F_SPEED_DUPLEX feature for virtio driver. There are two ways to specify speed of the link: * 'speed' devarg * negotiate speed from qemu via VIRTIO_NET_F_SPEED_DUPLEX The highest priority is devarg. If devarg is not specified, driver tries to negotiate it from qemu. Signed-off-by: Ivan Dyukov --- drivers/net/virtio/virtio_ethdev.c | 14 ++++++++++++++ drivers/net/virtio/virtio_ethdev.h | 3 ++- drivers/net/virtio/virtio_pci.h | 15 +++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index b757edfcc..46d699773 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1718,6 +1718,20 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features) hw->mac_addr[0], hw->mac_addr[1], hw->mac_addr[2], hw->mac_addr[3], hw->mac_addr[4], hw->mac_addr[5]); + if (vtpci_with_feature(hw, VIRTIO_NET_F_SPEED_DUPLEX)) { + config = &local_config; + /* if speed is not specified in devargs */ + if (hw->speed == ETH_SPEED_NUM_UNKNOWN) { + vtpci_read_dev_config(hw, + offsetof(struct virtio_net_config, speed), + &config->speed, sizeof(config->speed)); + hw->speed = config->speed; + } + } + + PMD_INIT_LOG(DEBUG, "link speed = %u%s", + hw->speed, hw->speed == ETH_SPEED_NUM_UNKNOWN ? + "(UNKNOWN)" : ""); if (vtpci_with_feature(hw, VIRTIO_NET_F_CTRL_VQ)) { config = &local_config; diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h index cd8947656..febaf17a8 100644 --- a/drivers/net/virtio/virtio_ethdev.h +++ b/drivers/net/virtio/virtio_ethdev.h @@ -37,7 +37,8 @@ 1ULL << VIRTIO_F_RING_PACKED | \ 1ULL << VIRTIO_F_IOMMU_PLATFORM | \ 1ULL << VIRTIO_F_ORDER_PLATFORM | \ - 1ULL << VIRTIO_F_NOTIFICATION_DATA) + 1ULL << VIRTIO_F_NOTIFICATION_DATA | \ + 1ULL << VIRTIO_NET_F_SPEED_DUPLEX) #define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES \ (VIRTIO_PMD_DEFAULT_GUEST_FEATURES | \ diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h index ed98e11c3..2948760ab 100644 --- a/drivers/net/virtio/virtio_pci.h +++ b/drivers/net/virtio/virtio_pci.h @@ -141,6 +141,9 @@ struct virtnet_ctl; */ #define VIRTIO_F_NOTIFICATION_DATA 38 +/* Device set linkspeed and duplex */ +#define VIRTIO_NET_F_SPEED_DUPLEX 63 + /* The Guest publishes the used index for which it expects an interrupt * at the end of the avail ring. Host should ignore the avail->flags field. */ /* The Host publishes the avail index for which it expects a kick @@ -306,6 +309,18 @@ struct virtio_net_config { uint16_t status; uint16_t max_virtqueue_pairs; uint16_t mtu; + /* + * speed, in units of 1Mb. All values 0 to INT_MAX are legal. + * Any other value stands for unknown. + */ + uint32_t speed; + /* + * 0x00 - half duplex + * 0x01 - full duplex + * Any other value stands for unknown. + */ + uint8_t duplex; + } __attribute__((packed)); /* -- 2.17.1