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 E84F0A0577; Mon, 6 Apr 2020 10:59:57 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1C0EE1BF6C; Mon, 6 Apr 2020 10:59:25 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 2C7DC1BF9B for ; Mon, 6 Apr 2020 10:59:23 +0200 (CEST) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200406085922euoutp02a0c4ae1a20a355bfe6f440bb14a32ece~DL1tNL8EQ1784717847euoutp02Y for ; Mon, 6 Apr 2020 08:59:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200406085922euoutp02a0c4ae1a20a355bfe6f440bb14a32ece~DL1tNL8EQ1784717847euoutp02Y DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1586163562; bh=0yV+ZZ6G+EJERFTpOP5JQNSOJC3qr5I3MXagyXr1fVw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=c3Q3p1duIG1z+AmprtxoTUpsn23KT96VLfgSVHdzSD8aRkJhyjUn75LzmueyLxfp0 HuF4OoSoNDrWR+YefhR6oaSla33F18Wfg1/pNpTQHUwtwtQrc9WDgmJUOAp3b5O81R gbd7u1lKEucB7klkLbR78105TydCMkqT+LG9aSF0= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200406085922eucas1p196b6d46e9faa3fddf6ae1ea6b63397cc~DL1s3QKco1225812258eucas1p1d; Mon, 6 Apr 2020 08:59:22 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id 57.56.60698.A6FEA8E5; Mon, 6 Apr 2020 09:59:22 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200406085922eucas1p2e1d78ccf211ba26ced03d466970b9b70~DL1sg7i2r2925429254eucas1p2P; Mon, 6 Apr 2020 08:59:22 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200406085922eusmtrp215a1b77fe1502d26f187f23dc45d8815~DL1scjEZt1429014290eusmtrp2l; Mon, 6 Apr 2020 08:59:22 +0000 (GMT) X-AuditID: cbfec7f5-a0fff7000001ed1a-bf-5e8aef6af6df Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 14.BB.07950.A6FEA8E5; Mon, 6 Apr 2020 09:59:22 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200406085921eusmtip2e0d922aabb3282bf134540eaec1a1ac2~DL1r245YL3064030640eusmtip2h; Mon, 6 Apr 2020 08:59:21 +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: Mon, 6 Apr 2020 11:58:03 +0300 Message-Id: <20200406085855.25773-6-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200406085855.25773-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMIsWRmVeSWpSXmKPExsWy7djP87pZ77viDFYdUbBo3fGAxeLdp+1M FrMuNbFbHOvcw2LR9+sqo8Xpm5vZLf68MbXYfHESkwOHx68FS1k9Fu95yeTxft9VNo++LasY PU496m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jxJ1n04EcDqCEhMTr J8wQNcISf651sUHUfGaU6PwD4nBysAloSJzumMcEkhAROM4o0TvrPxNIQljAQ+L2xJuMIDaL gKrE3okr2UFsXgFLiZ9vz0JNlZdYveEAmM0pYCUxZc9fFpDFQgIZEhsf5k1g5F3AyLCKUSS1 tDg3PbfYSK84Mbe4NC9dLzk/dxMjMEi3Hfu5ZQdj17vgQ4wCHIxKPLwMtzvjhFgTy4orcw8x SnAwK4nwSvUChXhTEiurUovy44tKc1KLDzGaAt00kVlKNDkfGEF5JfGGpobmFpaG5sbmxmYW SuK8HQIHY4QE0hNLUrNTUwtSi2D6mDg4pRoYZVXX+78qEb9888/ytw1v6lI59+w4uvHfxbOq Ef8PexyQ4q6pj/LRnFt1IC7t6r4/R/nLHHKPrkpWjq9+wqYcZRN99/shNt+Yy9NSHLKylVnt fM3/9sxp6Tf3idqYJ3l4+dQaBwZtZYG6P8usBa7VPtM0z1yQqvvvMT+bbf2rJa7cyYZTo7SV WIozEg21mIuKEwFbb/71aAIAAA== X-CMS-MailID: 20200406085922eucas1p2e1d78ccf211ba26ced03d466970b9b70 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200406085922eucas1p2e1d78ccf211ba26ced03d466970b9b70 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200406085922eucas1p2e1d78ccf211ba26ced03d466970b9b70 References: <20191212085012.9170-1-i.dyukov@samsung.com> <20200406085855.25773-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v9 5/5] 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. Set default speed to 0xffffffff and default duplex to 0xff There are few 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, drivers tries to negotiate it from qemu. Signed-off-by: Ivan Dyukov --- doc/guides/nics/virtio.rst | 4 ++-- drivers/net/virtio/virtio_ethdev.c | 16 +++++++++++++++- drivers/net/virtio/virtio_ethdev.h | 3 ++- drivers/net/virtio/virtio_pci.h | 15 +++++++++++++++ lib/librte_ethdev/rte_ethdev.h | 27 ++++++++++++++------------- 5 files changed, 48 insertions(+), 17 deletions(-) diff --git a/doc/guides/nics/virtio.rst b/doc/guides/nics/virtio.rst index e70b6653b..06c7a19aa 100644 --- a/doc/guides/nics/virtio.rst +++ b/doc/guides/nics/virtio.rst @@ -361,7 +361,7 @@ Below devargs are supported by the PCI virtio driver: It is used to specify link speed of virtio device, in units of 1Mb. Link speed is a part of link status structure. It could be requested by application using rte_eth_link_get_nowait function. - (Default: 10000 (10G)) + (Default: 0xffffffff (unknown)) Below devargs are supported by the virtio-user vdev: @@ -415,7 +415,7 @@ Below devargs are supported by the virtio-user vdev: It is used to specify link speed of virtio device, in units of 1Mb. Link speed is a part of link status structure. It could be requested by application using rte_eth_link_get_nowait function. - (Default: 10000 (10G)) + (Default: 0xffffffff (unknown)) Virtio paths Selection and Usage diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index eb46a5a11..0137efcc5 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; @@ -1865,7 +1879,7 @@ int eth_virtio_dev_init(struct rte_eth_dev *eth_dev) { struct virtio_hw *hw = eth_dev->data->dev_private; - uint32_t speed = ETH_SPEED_NUM_10G; + uint32_t speed = ETH_SPEED_NUM_UNKNOWN; int ret; if (sizeof(struct virtio_net_hdr_mrg_rxbuf) > RTE_PKTMBUF_HEADROOM) { 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)); /* diff --git a/lib/librte_ethdev/rte_ethdev.h b/lib/librte_ethdev/rte_ethdev.h index d1a593ad1..a15ea572e 100644 --- a/lib/librte_ethdev/rte_ethdev.h +++ b/lib/librte_ethdev/rte_ethdev.h @@ -287,19 +287,20 @@ struct rte_eth_stats { /** * Ethernet numeric link speeds in Mbps */ -#define ETH_SPEED_NUM_NONE 0 /**< Not defined */ -#define ETH_SPEED_NUM_10M 10 /**< 10 Mbps */ -#define ETH_SPEED_NUM_100M 100 /**< 100 Mbps */ -#define ETH_SPEED_NUM_1G 1000 /**< 1 Gbps */ -#define ETH_SPEED_NUM_2_5G 2500 /**< 2.5 Gbps */ -#define ETH_SPEED_NUM_5G 5000 /**< 5 Gbps */ -#define ETH_SPEED_NUM_10G 10000 /**< 10 Gbps */ -#define ETH_SPEED_NUM_20G 20000 /**< 20 Gbps */ -#define ETH_SPEED_NUM_25G 25000 /**< 25 Gbps */ -#define ETH_SPEED_NUM_40G 40000 /**< 40 Gbps */ -#define ETH_SPEED_NUM_50G 50000 /**< 50 Gbps */ -#define ETH_SPEED_NUM_56G 56000 /**< 56 Gbps */ -#define ETH_SPEED_NUM_100G 100000 /**< 100 Gbps */ +#define ETH_SPEED_NUM_NONE 0 /**< Not defined */ +#define ETH_SPEED_NUM_10M 10 /**< 10 Mbps */ +#define ETH_SPEED_NUM_100M 100 /**< 100 Mbps */ +#define ETH_SPEED_NUM_1G 1000 /**< 1 Gbps */ +#define ETH_SPEED_NUM_2_5G 2500 /**< 2.5 Gbps */ +#define ETH_SPEED_NUM_5G 5000 /**< 5 Gbps */ +#define ETH_SPEED_NUM_10G 10000 /**< 10 Gbps */ +#define ETH_SPEED_NUM_20G 20000 /**< 20 Gbps */ +#define ETH_SPEED_NUM_25G 25000 /**< 25 Gbps */ +#define ETH_SPEED_NUM_40G 40000 /**< 40 Gbps */ +#define ETH_SPEED_NUM_50G 50000 /**< 50 Gbps */ +#define ETH_SPEED_NUM_56G 56000 /**< 56 Gbps */ +#define ETH_SPEED_NUM_100G 100000 /**< 100 Gbps */ +#define ETH_SPEED_NUM_UNKNOWN 0xffffffff /**< Unknown */ /** * A structure used to retrieve link-level information of an Ethernet port. -- 2.17.1