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 E4B63A0563; Wed, 15 Apr 2020 22:05:38 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1C3D11DA34; Wed, 15 Apr 2020 22:04:54 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 3C2761DA29 for ; Wed, 15 Apr 2020 22:04:50 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200415200450euoutp01d32a4374644d9c7a220c45705ee929e9~GFuSn1zII2184721847euoutp01B for ; Wed, 15 Apr 2020 20:04:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200415200450euoutp01d32a4374644d9c7a220c45705ee929e9~GFuSn1zII2184721847euoutp01B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1586981090; bh=REinwRkqPLOjw+8vTqF2dhIciAY/lE5ROJDrE8KoQdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vLzG+giLH0LG1jHQiL9igNawJHcyRgF5Bvi5C5fIyNSrdJsZI73UysgAoTH+jFJV/ Yc9+tGkI+KVk9TFDy+oYeVhuNtmRYQxKWmr2HSeyMYGsMi947vCej/rH14fL6VVcu+ 2aDiuPhd4WM3OPhzkErB5B1p4BUHSiF/8jm53r68= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200415200449eucas1p24299f30f25877157b0a31f0346d08716~GFuR5FKSo1479314793eucas1p2h; Wed, 15 Apr 2020 20:04:49 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id DF.49.60698.1E8679E5; Wed, 15 Apr 2020 21:04:49 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200415200448eucas1p2ca449e8b15c2288adf202c7bf045fb9b~GFuRhdoP61479314793eucas1p2g; Wed, 15 Apr 2020 20:04:48 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200415200448eusmtrp20fcc3ffaa73d11349930a2350264e335~GFuRg66kC3157831578eusmtrp2N; Wed, 15 Apr 2020 20:04:48 +0000 (GMT) X-AuditID: cbfec7f5-a0fff7000001ed1a-22-5e9768e15c60 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 3E.27.07950.0E8679E5; Wed, 15 Apr 2020 21:04:48 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200415200448eusmtip1468cea8426b46c07dea869e42d7dd9a1~GFuQ57OTz1865818658eusmtip1N; Wed, 15 Apr 2020 20:04:48 +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 Cc: Ivan Dyukov Date: Wed, 15 Apr 2020 23:03:58 +0300 Message-Id: <20200415200423.6410-7-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200415200423.6410-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA0VSa0hTYRj2287OOTNnpznwTQNhFZaQl1Q6kWSCxPpTIfWjm3bUk5O8zB21 rH6ooC41U5GtJNQMtaY0m8N702ZoXkq8pRJqiiReKvBCpGY5z6R/D8/lfR4+PlIo1YhcyOi4 RFYdx8T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A2MK0W6GDk5JARMJJYtO84CYgsJLGWUOPtX uIuRAyguIfH6CTNEibDEn2tdbF2MXEAlnxklZjdtZANJsAloSJzumMcEkhAROM4o0TvrPxNI gllAXeLixvtg3cICnhKH26awgAxlEVCV+LRQCiTMK2Ah0bjgACPEAnmJ1RsOgJVzClhKbLt0 iA3innSJJd09TBMY+RYwMqxiFEktLc5Nzy020itOzC0uzUvXS87P3cQIDOdtx35u2cHY9S74 EKMAB6MSD2/H62lxQqyJZcWVuYcYJTiYlUR4d/hPjxPiTUmsrEotyo8vKs1JLT7EaAp000Rm KdHkfGCs5ZXEG5oamltYGpobmxubWSiJ83YIHIwBOiOxJDU7NbUgtQimj4mDU6qBMTBm2lSV a/dizl9u/6xawL9x3duCx133dnT5Hz/nzlKu0XN8zwrR1c8brI1yt8cGuvm6vxfq2H6tXu+B jY2H94KJDbphKgu/nV9yQtj8iucjqfvaxeVM/HxcV/LdHmpwaXW+0wrPepMd4RsTfefFed13 jO5CiieqWKTnygXsejJdfFO4f6KrEktxRqKhFnNRcSIAOshVS30CAAA= X-CMS-MailID: 20200415200448eucas1p2ca449e8b15c2288adf202c7bf045fb9b X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200415200448eucas1p2ca449e8b15c2288adf202c7bf045fb9b X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200415200448eucas1p2ca449e8b15c2288adf202c7bf045fb9b References: <20191212085012.9170-1-i.dyukov@samsung.com> <20200415200423.6410-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v10 6/6] 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 306241d37..b08270714 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