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 8A141A053B; Thu, 6 Feb 2020 15:26:52 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 637771C10D; Thu, 6 Feb 2020 15:26:52 +0100 (CET) Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by dpdk.org (Postfix) with ESMTP id D52261C0DB for ; Thu, 6 Feb 2020 15:26:50 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580999210; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:autocrypt:autocrypt; bh=cTHnBiiGwdcTLsjZaspgT/iLID58GuylbHPF51s8i5I=; b=AjHdQTpnVDkOv8wJonIWFDQMmCeYQHq0Te7iCvYoxtb1t8Y17STjzaekZ1+tT5eZo5M2XA BVW6KMfnvM7cBnmsyYQqHG26zq2ZHdwyLINmtTXyxXM89ORBH7yAc2GdUITPA6LlBZbvdl SEs+RPRaftJlB2oFXapIa1kNfybUJ3M= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-190-qW76ONaTNC67IUnDIObrgw-1; Thu, 06 Feb 2020 09:26:48 -0500 Received: by mail-wm1-f72.google.com with SMTP id a10so39896wme.9 for ; Thu, 06 Feb 2020 06:26:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:autocrypt:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=cTHnBiiGwdcTLsjZaspgT/iLID58GuylbHPF51s8i5I=; b=Ib2ieOmROU4z90nzuRVusbgT1pXLgxFoLQ61kncnNXdJUvXpTFnqYIb+liEOYdAhZC 6fPc7TEF4PzmrW7KiBAfrUJe5z7tW3vJlnKmYlzrGX+bDJA3+3p4rnLyJPbGpCbfJoWt BZ/6k6eD6BMrtsJ9SYX0y5LYGlqrir83B5J6xu6tnXVLpbL2dfqEGFHITTKer+Ahu6Hi h5qhR8riQHkpR5PH4FI/6a0GuxMU2JP+JF2PLij797I7h0anRhRVNNE+uZGx1YCjfJu0 Uce4StBq7u3Ybx8/NQXj9EpjHclhs4mnxOvl/NggthUF9ct5IYJbQT4p8adr/9YCQWCM PKPw== X-Gm-Message-State: APjAAAVhfpvn4UIefLQHPFaAXUkX9MdIFEyXzCrbDVmQneW4fmIYDnss 6BflhfZkW3dSmZHPcIZF+oNOabkCm3vZckv+wCLOr/C+VT3b6+7K9sqtvNi53vD9XU9aBsiqo76 Bdk8= X-Received: by 2002:a1c:3b09:: with SMTP id i9mr4783203wma.31.1580999207067; Thu, 06 Feb 2020 06:26:47 -0800 (PST) X-Google-Smtp-Source: APXvYqxTyMIyj1K503DxsXjsQ1XgOWQCjmGtgD9wqUuynImL8wPKsVXMgtxmLijVQ2U3k/fD2eHP1w== X-Received: by 2002:a1c:3b09:: with SMTP id i9mr4783188wma.31.1580999206819; Thu, 06 Feb 2020 06:26:46 -0800 (PST) Received: from amorenoz.users.ipa.redhat.com ([62.97.79.170]) by smtp.gmail.com with ESMTPSA id b17sm4377700wrp.49.2020.02.06.06.26.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 06 Feb 2020 06:26:46 -0800 (PST) To: Maxime Coquelin , dev@dpdk.org, Ivan Dyukov References: <20200120170520.24192-1-i.dyukov@samsung.com> <20200120170520.24192-2-i.dyukov@samsung.com> <686c6268-ac3e-cf5d-8318-6985b146e646@redhat.com> From: Adrian Moreno Autocrypt: addr=amorenoz@redhat.com; prefer-encrypt=mutual; keydata= mQENBF1syNUBCADQ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tRRH1kNyrCSbTG0d9MtcQO58h7DLXuzUhErB+BtG52A04t5cweIJTJC+koV5XPeilzlHnm RFoj0ncruGa9Odns21BNt3cy9wLfK+aUnWuAB1uc6bJGQPiAwjkilz7g7MBRUuIQ2Zt7HGLc SwARAQABiQE8BBgBCAAmFiEEogUDgihhmbOPHy26d5C5fbYeFsUFAl1syNUCGwwFCQHhM4AA CgkQd5C5fbYeFsUlSwf8CH+u/IXaE7WeWxwFkMaORfW8cM4q0xrL3M6yRGuQNW+kMjnrvK9U J9G+L1/5uTRbDQ/4LdoKqize8LjehA+iF6ba4t9Npikh8fLKWgaJfQ/hPhH4C3O5gWPOLTW6 ylGxiuER4CdFwQIoAMMslhFA7G+teeOKBq36E+1+zrybI6Xy1UBSlpDK9j4CtTnMQejjuSQb Qhle+l8VroaUHq869wjAhRHHhqmtJKggI+OvzgQpDIwfHIDypb1BuKydi2W6cVYEALUYyCLS dTBDhzj8zR5tPCsga8J7+TclQzkWOiI2C6ZtiWrMsL/Uym3uXk5nsoc7lSj7yLd/MrBRhYfP JQ== Message-ID: <84cb38b1-5d22-f6b0-4d42-900f5b2a370a@redhat.com> Date: Thu, 6 Feb 2020 15:26:45 +0100 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: Content-Language: en-US X-MC-Unique: qW76ONaTNC67IUnDIObrgw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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" 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. 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; >>> >> >