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 DF303A0588; Thu, 16 Apr 2020 07:54:26 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id DBE8D1DAD1; Thu, 16 Apr 2020 07:53:37 +0200 (CEST) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 636A11DAC5 for ; Thu, 16 Apr 2020 07:53:34 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200416055334euoutp02124d949cb23e50a94812f1040fd8d48a~GNwU2DRPu3070430704euoutp029 for ; Thu, 16 Apr 2020 05:53:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200416055334euoutp02124d949cb23e50a94812f1040fd8d48a~GNwU2DRPu3070430704euoutp029 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1587016414; bh=jp3mL7gxzLIRM9vHdEqRM1DYLKk2CkbIOcMocMzU1dU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=SYA3FGi1LpzUDvxE4Ew86UPH5tRl8jLriX1uwaUgZ5g1pY3tHbhVb+t2/APL6jCUF 4o3MzBNMEZUdUXzjwygdRK5KEBhx0ysyo0o51mXqJLhXnVyDGXxzp7TwoQokW0oLOy /Bnsvb1iNJVlLqcIKrfqpT7VoezzryXNr+pCL0sw= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20200416055333eucas1p1774139ce67fe882ad77e4d8ca23c2a3e~GNwUK5XSr1378713787eucas1p1V; Thu, 16 Apr 2020 05:53:33 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 0F.91.61286.DD2F79E5; Thu, 16 Apr 2020 06:53:33 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200416055333eucas1p15fe1459edef84852c7131443b54fdeed~GNwTzg5EA1444714447eucas1p1U; Thu, 16 Apr 2020 05:53:33 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20200416055333eusmtrp179435e6b05ce84879738cdf21778fd74~GNwTy9CyB2731027310eusmtrp1F; Thu, 16 Apr 2020 05:53:33 +0000 (GMT) X-AuditID: cbfec7f2-f0bff7000001ef66-22-5e97f2ddb177 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id E3.FE.08375.CD2F79E5; Thu, 16 Apr 2020 06:53:33 +0100 (BST) Received: from idyukov.rnd.samsung.ru (unknown [106.109.129.29]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200416055332eusmtip2069f4a659f15ccd2bb158c402d5c4da2~GNwTPCAEx2412824128eusmtip2g; Thu, 16 Apr 2020 05:53:32 +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 08:53:06 +0300 Message-Id: <20200416055309.19679-7-i.dyukov@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416055309.19679-1-i.dyukov@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCIsWRmVeSWpSXmKPExsWy7djP87p3P02PM2g4JGXRuuMBi8W7T9uZ LGZdamK3ONa5h8Wi79dVRovTNzezW/x5Y2qx+eIkJgcOj18LlrJ6LN7zksnj/b6rbB59W1Yx epx61M0cwBrFZZ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9QIS/y51sUGUfOZUeLwn5vsIAk2AQ2J0x3zmEASIgLHGSV6Z/1nAkkIC3hKHG5rZwGx WQRUJabvvwEW5xWwlNh5uYsRYqq8xOoNB8A2cApYSRzoPgNWIySQIdHYcYxpAiPvAkaGVYwi qaXFuem5xYZ6xYm5xaV56XrJ+bmbGIFhuu3Yz807GC9tDD7EKMDBqMTD2/F6WpwQa2JZcWXu IUYJDmYlEd4d/tPjhHhTEiurUovy44tKc1KLDzGaAh01kVlKNDkfGEN5JfGGpobmFpaG5sbm xmYWSuK8HQIHY4QE0hNLUrNTUwtSi2D6mDg4pRoY5x9cmf/k24ydLIa/m7m4PMIzHi314tbq 2uMso7s56aGjsEjV0ju5dYauPkFaU94tmsnhciMl23uly7vA1bIvG1183UQ1jDce25d22v73 jrWuz72k438f3//z1fYDj94tO3MvMfwvd76BNOe/n5/jrIMeNv7mPJwlEHfrlunjb5JOL9wU 2z5ZK7EUZyQaajEXFScCACk7PwdpAgAA X-CMS-MailID: 20200416055333eucas1p15fe1459edef84852c7131443b54fdeed X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200416055333eucas1p15fe1459edef84852c7131443b54fdeed X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200416055333eucas1p15fe1459edef84852c7131443b54fdeed References: <20191212085012.9170-1-i.dyukov@samsung.com> <20200416055309.19679-1-i.dyukov@samsung.com> Subject: [dpdk-dev] [PATCH v11 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