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 C7514A0542; Fri, 7 Feb 2020 12:34:57 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 331A21C0C2; Fri, 7 Feb 2020 12:34:57 +0100 (CET) Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by dpdk.org (Postfix) with ESMTP id 8C01F1C0BC for ; Fri, 7 Feb 2020 12:34:55 +0100 (CET) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20200207113454euoutp02c31357a82db0e22a84d7f384ac0c3acf~xG5p-FUJK1151111511euoutp02X for ; Fri, 7 Feb 2020 11:34:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20200207113454euoutp02c31357a82db0e22a84d7f384ac0c3acf~xG5p-FUJK1151111511euoutp02X DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1581075294; bh=L8ZakO3NPgZxBQsUJnvO7ZFyAoHvmMQZn2VZ1UDo/7s=; h=Subject:To:From:Date:In-Reply-To:References:From; b=pbCwREy2oY0tCtlKHdT9fP5euJzy3wu2v2QcGm/1E3EUabvnAfDGMkpg6V+f2Y0Eb 1FmseoGYdO/tq14Nn28e0De6bVES6eLpsoXNK+s+xz7mrRM5wcuIEP3z6GUAlnDupZ AAHOOoNQczMGcEm0JheldimGIqKh4vk+MDhiiAAU= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200207113454eucas1p24f5292c95439cb0fbfe05361f845d81c~xG5p2Ha5g1679716797eucas1p2a; Fri, 7 Feb 2020 11:34:54 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 2F.7D.61286.E5B4D3E5; Fri, 7 Feb 2020 11:34:54 +0000 (GMT) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20200207113453eucas1p233e24647bc8d7c6d00b0fdf80b5db2c3~xG5pV73TC2566225662eucas1p2J; Fri, 7 Feb 2020 11:34:53 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200207113453eusmtrp28c282cc297d397d247a1fc181bb97822~xG5pVaA0G1436914369eusmtrp2Q; Fri, 7 Feb 2020 11:34:53 +0000 (GMT) X-AuditID: cbfec7f2-f0bff7000001ef66-8c-5e3d4b5e6932 Received: from eusmtip2.samsung.com ( [203.254.199.222]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id B0.CE.07950.D5B4D3E5; Fri, 7 Feb 2020 11:34:53 +0000 (GMT) Received: from [106.109.129.29] (unknown [106.109.129.29]) by eusmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200207113453eusmtip24bd8ffa68c828af05ae3e4d0d0b89bae~xG5pA10eA0031400314eusmtip2Q; Fri, 7 Feb 2020 11:34:53 +0000 (GMT) To: Adrian Moreno , Maxime Coquelin , dev@dpdk.org From: Ivan Dyukov Message-ID: <67a2de42-84ea-337b-2e9a-654c79e15f0a@samsung.com> Date: Fri, 7 Feb 2020 14:34:53 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <84cb38b1-5d22-f6b0-4d42-900f5b2a370a@redhat.com> Content-Transfer-Encoding: 8bit Content-Language: ru-RU X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjleLIzCtJLcpLzFFi42LZduznOd04b9s4g3+/BS1adzxgsXj3aTuT xbHOPSwOzB6/Fixl9Xi/7ypbAFMUl01Kak5mWWqRvl0CV8b+lytZCn7Y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rZoUo uskkMfHTD3aQBJuAhsTpjnlgRbwCdhInX01lAbFZBFQkriz5DhYXFYiQeDyxnRGiRlDi5Mwn YDWcQPWfFm9iBbGZBcwk5m1+yAxhy0s0b50NZYtLfNh+kG0Co+AsJO2zkLTMQtIyC0nLAkaW VYwiqaXFuem5xUZ6xYm5xaV56XrJ+bmbGIGRse3Yzy07GLveBR9iFOBgVOLhTXC0iRNiTSwr rsw9xCjBwawkwtunahsnxJuSWFmVWpQfX1Sak1p8iNEU6LmJzFKiyfnAqM0riTc0NTS3sDQ0 NzY3NrNQEuftEDgYIySQnliSmp2aWpBaBNPHxMEp1cB4OEPv6cqV6xcqW/IKl0Wmnc8t28Pa u3HSzb95xYe8OXqsU125nttvZmq/9DmSf8ZrlpQyn1utkzk6cqUWHN1oxPVx/zsfjxNPZ9t9 mfM+vK+is0PqnEQ40/TpLGeb3/1L9s0z2KL8qk2i+97HJMnraz3n/Lnk8Ns4//tf7r0lwn/q WA1L5z1VYinOSDTUYi4qTgQAGP+mI6ICAAA= X-CMS-MailID: 20200207113453eucas1p233e24647bc8d7c6d00b0fdf80b5db2c3 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200120170531eucas1p218252a80fbf9252baf21921f8c72fe82 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200120170531eucas1p218252a80fbf9252baf21921f8c72fe82 References: <20200120170520.24192-1-i.dyukov@samsung.com> <20200120170520.24192-2-i.dyukov@samsung.com> <686c6268-ac3e-cf5d-8318-6985b146e646@redhat.com> <84cb38b1-5d22-f6b0-4d42-900f5b2a370a@redhat.com> Subject: Re: [dpdk-dev] [PATCH v2 2/2] net/virtio: add link speed devarg 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" Hi Maxime, Adrian, Thank you for comments!  I have sent new patch with updated documentation. This is not final version of the link speed. I still have plan to rework it and use link speed which is stored in qemu. Best regards, Ivan 06.02.2020 17:26, Adrian Moreno пишет: > On 2/6/20 3:22 PM, Maxime Coquelin wrote: >> Adding back Ivan as you removed it from the To: list. >> So he may not have seen your comment. I really missed it. Thanks. > Oops, sorry about that. > Adrian >> On 1/29/20 11:10 AM, Adrian Moreno wrote: >>> On 1/20/20 6:05 PM, Ivan Dyukov wrote: >>>> Some applications like pktgen use link_speed to calculate >>>> transmit rate. It limits outcome traffic to hardcoded 10G. >>>> >>>> This patch adds link_speed devarg which allows to configure >>>> link_speed of virtio device. >>>> >>>> Signed-off-by: Ivan Dyukov >>>> --- >>>> drivers/net/virtio/virtio_ethdev.c | 101 ++++++++++++++++++++++++----- >>>> drivers/net/virtio/virtio_pci.h | 1 + >>>> 2 files changed, 85 insertions(+), 17 deletions(-) >>>> >>> Hi Ivan, >>> >>> IMHO, this new option deserves being documented in doc/guides/nics/virtio.rst. >>> >>> Otherwise it looks good to me. >> I agree with Adrian here, the new option need to be documented. >> >> Thanks, >> Maxime >> >>> Thank you. >>> Adrian >>>> diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c >>>> index 22323d9a5..5ef3c11a7 100644 >>>> --- a/drivers/net/virtio/virtio_ethdev.c >>>> +++ b/drivers/net/virtio/virtio_ethdev.c >>>> @@ -45,6 +45,10 @@ static int virtio_dev_promiscuous_enable(struct rte_eth_dev *dev); >>>> static int virtio_dev_promiscuous_disable(struct rte_eth_dev *dev); >>>> static int virtio_dev_allmulticast_enable(struct rte_eth_dev *dev); >>>> static int virtio_dev_allmulticast_disable(struct rte_eth_dev *dev); >>>> +static uint32_t virtio_dev_speed_capa_get(uint32_t link_speed); >>>> +static int virtio_dev_devargs_parse(struct rte_devargs *devargs, >>>> + int *vdpa, >>>> + uint32_t *link_speed); >>>> static int virtio_dev_info_get(struct rte_eth_dev *dev, >>>> struct rte_eth_dev_info *dev_info); >>>> static int virtio_dev_link_update(struct rte_eth_dev *dev, >>>> @@ -1861,6 +1865,7 @@ int >>>> eth_virtio_dev_init(struct rte_eth_dev *eth_dev) >>>> { >>>> struct virtio_hw *hw = eth_dev->data->dev_private; >>>> + uint32_t link_speed = ETH_SPEED_NUM_10G; >>>> int ret; >>>> >>>> if (sizeof(struct virtio_net_hdr_mrg_rxbuf) > RTE_PKTMBUF_HEADROOM) { >>>> @@ -1886,7 +1891,11 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) >>>> >>>> return 0; >>>> } >>>> - >>>> + ret = virtio_dev_devargs_parse(eth_dev->device->devargs, >>>> + NULL, &link_speed); >>>> + if (ret < 0) >>>> + return ret; >>>> + hw->link_speed = link_speed; >>>> /* >>>> * Pass the information to the rte_eth_dev_close() that it should also >>>> * release the private port resources. >>>> @@ -1953,6 +1962,14 @@ eth_virtio_dev_uninit(struct rte_eth_dev *eth_dev) >>>> >>>> return 0; >>>> } >>>> +#define VIRTIO_ARG_LINK_SPEED "link_speed" >>>> +#define VIRTIO_ARG_VDPA "vdpa" >>>> + >>>> +static const char * const valid_args[] = { >>>> + VIRTIO_ARG_LINK_SPEED, >>>> + VIRTIO_ARG_VDPA, >>>> + NULL >>>> +}; >>>> >>>> static int vdpa_check_handler(__rte_unused const char *key, >>>> const char *value, void *ret_val) >>>> @@ -1965,33 +1982,84 @@ static int vdpa_check_handler(__rte_unused const char *key, >>>> return 0; >>>> } >>>> >>>> + >>>> +static uint32_t >>>> +virtio_dev_speed_capa_get(uint32_t link_speed) >>>> +{ >>>> + switch (link_speed) { >>>> + case ETH_SPEED_NUM_10G: >>>> + return ETH_LINK_SPEED_10G; >>>> + case ETH_SPEED_NUM_20G: >>>> + return ETH_LINK_SPEED_20G; >>>> + case ETH_SPEED_NUM_25G: >>>> + return ETH_LINK_SPEED_25G; >>>> + case ETH_SPEED_NUM_40G: >>>> + return ETH_LINK_SPEED_40G; >>>> + case ETH_SPEED_NUM_50G: >>>> + return ETH_LINK_SPEED_50G; >>>> + case ETH_SPEED_NUM_56G: >>>> + return ETH_LINK_SPEED_56G; >>>> + case ETH_SPEED_NUM_100G: >>>> + return ETH_LINK_SPEED_100G; >>>> + default: >>>> + return 0; >>>> + } >>>> +} >>>> + >>>> +static int link_speed_handler(const char *key __rte_unused, >>>> + const char *value, void *ret_val) >>>> +{ >>>> + uint32_t val; >>>> + if (!value || !ret_val) >>>> + return -EINVAL; >>>> + val = strtoul(value, NULL, 0); >>>> + /* validate input */ >>>> + if (virtio_dev_speed_capa_get(val) == 0) >>>> + return -EINVAL; >>>> + *(uint32_t *)ret_val = val; >>>> + >>>> + return 0; >>>> +} >>>> + >>>> + >>>> static int >>>> -virtio_dev_devargs_parse(struct rte_devargs *devargs, int *vdpa) >>>> +virtio_dev_devargs_parse(struct rte_devargs *devargs, int *vdpa, >>>> + uint32_t *link_speed) >>>> { >>>> struct rte_kvargs *kvlist; >>>> - const char *key = "vdpa"; >>>> int ret = 0; >>>> >>>> if (devargs == NULL) >>>> return 0; >>>> >>>> - kvlist = rte_kvargs_parse(devargs->args, NULL); >>>> - if (kvlist == NULL) >>>> + kvlist = rte_kvargs_parse(devargs->args, valid_args); >>>> + if (kvlist == NULL) { >>>> + PMD_INIT_LOG(ERR, "error when parsing param"); >>>> return 0; >>>> - >>>> - if (!rte_kvargs_count(kvlist, key)) >>>> - goto exit; >>>> - >>>> - if (vdpa) { >>>> + } >>>> + if (vdpa && rte_kvargs_count(kvlist, VIRTIO_ARG_VDPA) == 1) { >>>> /* vdpa mode selected when there's a key-value pair: >>>> * vdpa=1 >>>> */ >>>> - ret = rte_kvargs_process(kvlist, key, >>>> + ret = rte_kvargs_process(kvlist, VIRTIO_ARG_VDPA, >>>> vdpa_check_handler, vdpa); >>>> - if (ret < 0) >>>> + if (ret < 0) { >>>> + PMD_INIT_LOG(ERR, "error to parse %s", >>>> + VIRTIO_ARG_VDPA); >>>> goto exit; >>>> + } >>>> + } >>>> + if (link_speed && >>>> + rte_kvargs_count(kvlist, VIRTIO_ARG_LINK_SPEED) == 1) { >>>> + ret = rte_kvargs_process(kvlist, >>>> + VIRTIO_ARG_LINK_SPEED, >>>> + link_speed_handler, link_speed); >>>> + if (ret < 0) { >>>> + PMD_INIT_LOG(ERR, "error to parse %s", >>>> + VIRTIO_ARG_LINK_SPEED); >>>> + goto exit; >>>> + } >>>> } >>>> - >>>> >>>> exit: >>>> rte_kvargs_free(kvlist); >>>> @@ -2004,7 +2072,7 @@ static int eth_virtio_pci_probe(struct rte_pci_driver *pci_drv __rte_unused, >>>> int vdpa = 0; >>>> int ret = 0; >>>> >>>> - ret = virtio_dev_devargs_parse(pci_dev->device.devargs, &vdpa); >>>> + ret = virtio_dev_devargs_parse(pci_dev->device.devargs, &vdpa, NULL); >>>> if (ret < 0) { >>>> PMD_DRV_LOG(ERR, >>>> "devargs parsing is failed"); >>>> @@ -2386,7 +2454,7 @@ virtio_dev_link_update(struct rte_eth_dev *dev, __rte_unused int wait_to_complet >>>> >>>> memset(&link, 0, sizeof(link)); >>>> link.link_duplex = ETH_LINK_FULL_DUPLEX; >>>> - link.link_speed = ETH_SPEED_NUM_10G; >>>> + link.link_speed = hw->link_speed; >>>> link.link_autoneg = ETH_LINK_FIXED; >>>> >>>> if (!hw->started) { >>>> @@ -2441,8 +2509,7 @@ virtio_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) >>>> { >>>> uint64_t tso_mask, host_features; >>>> struct virtio_hw *hw = dev->data->dev_private; >>>> - >>>> - dev_info->speed_capa = ETH_LINK_SPEED_10G; /* fake value */ >>>> + dev_info->speed_capa = virtio_dev_speed_capa_get(hw->link_speed); >>>> >>>> dev_info->max_rx_queues = >>>> RTE_MIN(hw->max_queue_pairs, VIRTIO_MAX_RX_QUEUES); >>>> diff --git a/drivers/net/virtio/virtio_pci.h b/drivers/net/virtio/virtio_pci.h >>>> index a38cb45ad..688eda914 100644 >>>> --- a/drivers/net/virtio/virtio_pci.h >>>> +++ b/drivers/net/virtio/virtio_pci.h >>>> @@ -253,6 +253,7 @@ struct virtio_hw { >>>> uint16_t port_id; >>>> uint8_t mac_addr[RTE_ETHER_ADDR_LEN]; >>>> uint32_t notify_off_multiplier; >>>> + uint32_t link_speed; /* link speed in MB */ >>>> uint8_t *isr; >>>> uint16_t *notify_base; >>>> struct virtio_pci_common_cfg *common_cfg; >>>> >