From patchwork Fri Mar 5 19:42:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ajit Khaparde X-Patchwork-Id: 88590 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6C761A054F; Fri, 5 Mar 2021 20:42:42 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F278640692; Fri, 5 Mar 2021 20:42:41 +0100 (CET) Received: from mail-pj1-f42.google.com (mail-pj1-f42.google.com [209.85.216.42]) by mails.dpdk.org (Postfix) with ESMTP id ECF8B40147 for ; Fri, 5 Mar 2021 20:42:40 +0100 (CET) Received: by mail-pj1-f42.google.com with SMTP id o6so2717349pjf.5 for ; Fri, 05 Mar 2021 11:42:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version; bh=hW6NSn9o01kZeSGnFfo0xc2WXQ51fz+wXwUaiX2bZNc=; b=UgdIHRMk2be0bYrMqp503+ZGozik0YHvrN1Xy+dTryAawA9c+bN0A9brZiifNc/iP0 fOfeunWYpe27XlzM1Sbz0cyPy/ifDU/06WdVG5Ybszw17iqKFBYFyG8rDpMpb1RlHBy0 nWnivOdS1/EhGCIt0BeaWrUVyf6QaSDPAMDuU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version; bh=hW6NSn9o01kZeSGnFfo0xc2WXQ51fz+wXwUaiX2bZNc=; b=Ff5bcs5Do8JuVVmuCH5wwb8LKKlvy/Vk/m2FcGzlWtnk01Tp7gXHONOnuapJIe740K JLHKilF4jkNUtSfjHWBTtxnSWfrFUedQ+h67wtuJJ8l4WGyTnF5n66N4hDrSL7XtxXOs BsIWsg+B8bGaTXxy897z5zgY1xJRek+BW6/4D2ajbD9GM+13UfKKOCkkwI5tsKOmrerz OgurRrx3rT2ONSDwh4473sSSKL/BmgfEVTbhHHA0xGHNk0iRUvGymVRMLvi5TAx92BHy 3JVX3RaL270SvDPqP6SGdU3ApmRLCWw2CvcBJYdcyqDZMTmc4bxdpNpy+SachSTlfLks bZ7Q== X-Gm-Message-State: AOAM531AMZAAEiWWBS2NxrDF5jhQ6zFFhC6HuDJnPuidZEVLm4Pej438 dEAR06u3kTXZ5/Wqm4BJPuBmiNewneOzkfkxZ9L7mN4rrJWC0TDvzy8G3oEZrPj7HSqZLff26NY Ty5ya4xpsSuwsq9zooEDkrOujgsKsqAaBycP046buU+pzsst5yX8DqUcgXR/NMO1UQw== X-Google-Smtp-Source: ABdhPJyCH06Qhzr8PzbfXBmHRUyAl6ms9wsl2FqchJvEUyaaraaQfG69uNbIQKhBoQFKwTZXsZKSYQ== X-Received: by 2002:a17:90b:f15:: with SMTP id br21mr6657104pjb.234.1614973359271; Fri, 05 Mar 2021 11:42:39 -0800 (PST) Received: from localhost.localdomain ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id e24sm3452053pgl.81.2021.03.05.11.42.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Mar 2021 11:42:38 -0800 (PST) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Fri, 5 Mar 2021 11:42:32 -0800 Message-Id: <20210305194232.45026-1-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.21.1 (Apple Git-122.3) In-Reply-To: <590c4af0-9650-3ccc-c758-51c434bb8f1e@intel.com> References: <590c4af0-9650-3ccc-c758-51c434bb8f1e@intel.com> MIME-Version: 1.0 X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [dpdk-dev] [PATCH v3] app/testpmd: add support for forced ethernet speed X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Add support for forced ethernet speed setting. Currently testpmd tries to configure the Ethernet port in autoneg mode. It is not possible to set the Ethernet port to a specific speed while starting testpmd. In some cases capability to configure a forced speed for the Ethernet port during initialization may be necessary. This patch tries to add this support. The patch assumes full duplex setting and does not attempt to change that. So speeds like 10M, 100M are not configurable using this method. The command line to configure a forced speed of 10G: dpdk-testpmd -c 0xff -- -i --eth-link-speed 10000 The command line to configure a forced speed of 50G: dpdk-testpmd -c 0xff -- -i --eth-link-speed 50000 Signed-off-by: Ajit Khaparde ---- v1->v2: - Updated the release notes to document the new parameter. - Updated the user guide to indicate 10 and 100 Mbps are not supported. - Check and return error if 10 or 100Mbps speeds are requested. - Set ETH_LINK_SPEED_FIXED when requesting forced link speed. - Updated code based on other review comments. v2>v3: - Updated the user guide to correct formatting issues. Please apply. Reviewed-by: Ferruh Yigit --- app/test-pmd/parameters.c | 44 ++++++++++++++++++++++++++ app/test-pmd/testpmd.c | 8 +++++ app/test-pmd/testpmd.h | 1 + doc/guides/rel_notes/release_21_05.rst | 3 ++ doc/guides/testpmd_app_ug/run_app.rst | 15 +++++++++ 5 files changed, 71 insertions(+) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index c8acd5d1b7..c5dac33b0f 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -224,6 +224,7 @@ usage(char* progname) printf(" --hairpin-mode=0xXX: bitmask set the hairpin port mode.\n " " 0x10 - explicit Tx rule, 0x02 - hairpin ports paired\n" " 0x01 - hairpin ports loop, 0x00 - hairpin port self\n"); + printf(" --eth-link-speed: forced link speed.\n"); } #ifdef RTE_LIB_CMDLINE @@ -485,6 +486,43 @@ parse_event_printing_config(const char *optarg, int enable) return 0; } +static int +parse_link_speed(int n) +{ + uint32_t speed = ETH_LINK_SPEED_FIXED; + + switch (n) { + case 1000: + speed |= ETH_LINK_SPEED_1G; + break; + case 10000: + speed |= ETH_LINK_SPEED_10G; + break; + case 25000: + speed |= ETH_LINK_SPEED_25G; + break; + case 40000: + speed |= ETH_LINK_SPEED_40G; + break; + case 50000: + speed |= ETH_LINK_SPEED_50G; + break; + case 100000: + speed |= ETH_LINK_SPEED_100G; + break; + case 200000: + speed |= ETH_LINK_SPEED_200G; + break; + case 100: + case 10: + default: + printf("Unsupported fixed speed\n"); + return 0; + } + + return speed; +} + void launch_args_parse(int argc, char** argv) { @@ -605,6 +643,7 @@ launch_args_parse(int argc, char** argv) { "rx-mq-mode", 1, 0, 0 }, { "record-core-cycles", 0, 0, 0 }, { "record-burst-stats", 0, 0, 0 }, + { "eth-link-speed", 1, 0, 0 }, { 0, 0, 0, 0 }, }; @@ -1366,6 +1405,11 @@ launch_args_parse(int argc, char** argv) record_core_cycles = 1; if (!strcmp(lgopts[opt_idx].name, "record-burst-stats")) record_burst_stats = 1; + if (!strcmp(lgopts[opt_idx].name, "eth-link-speed")) { + n = atoi(optarg); + if (n >= 0 && parse_link_speed(n) > 0) + eth_link_speed = parse_link_speed(n); + } break; case 'h': usage(argv[0]); diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 1a57324b1b..98c3248c01 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -513,6 +513,11 @@ uint8_t gro_flush_cycles = GRO_DEFAULT_FLUSH_CYCLES; */ enum rte_eth_rx_mq_mode rx_mq_mode = ETH_MQ_RX_VMDQ_DCB_RSS; +/* + * Used to set forced link speed + */ +uint32_t eth_link_speed; + /* Forward function declarations */ static void setup_attached_port(portid_t pi); static void check_all_ports_link_status(uint32_t port_mask); @@ -1484,6 +1489,9 @@ init_config(void) port->tx_conf[k].offloads = port->dev_conf.txmode.offloads; + if (eth_link_speed) + port->dev_conf.link_speeds = eth_link_speed; + /* set flag to initialize port/queue */ port->need_reconfig = 1; port->need_reconfig_queues = 1; diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index ce83f31f0d..0f54bcc346 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -353,6 +353,7 @@ extern bool setup_on_probe_event; /**< disabled by port setup-on iterator */ extern uint8_t hot_plug; /**< enable by "--hot-plug" parameter */ extern int do_mlockall; /**< set by "--mlockall" or "--no-mlockall" parameter */ extern uint8_t clear_ptypes; /**< disabled by set ptype cmd */ +extern uint32_t eth_link_speed; #ifdef RTE_LIBRTE_IXGBE_BYPASS extern uint32_t bypass_timeout; /**< Store the NIC bypass watchdog timeout */ diff --git a/doc/guides/rel_notes/release_21_05.rst b/doc/guides/rel_notes/release_21_05.rst index ca28d05d59..dde652dddf 100644 --- a/doc/guides/rel_notes/release_21_05.rst +++ b/doc/guides/rel_notes/release_21_05.rst @@ -64,6 +64,9 @@ New Features * Added command to display Rx queue used descriptor count. ``show port (port_id) rxq (queue_id) desc used count`` + * Added a command line option to configure forced speed for Ethernet port. + ``dpdk-testpmd -c 0xff -- -i --eth-link-speed N`` + Removed Items ------------- diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index 6745072329..3035118cdc 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -536,3 +536,18 @@ The command line options are: bit 1 - two hairpin ports paired bit 0 - two hairpin ports loop The default value is 0. Hairpin will use single port mode and implicit Tx flow mode. + +* ``--eth-link-speed`` + + Set a forced link speed to the ethernet port:: + + 10 - 10Mbps (not supported) + 100 - 100Mbps (not supported) + 1000 - 1Gbps + 10000 - 10Gbps + 25000 - 25Gbps + 40000 - 40Gbps + 50000 - 50Gbps + 100000 - 100Gbps + 200000 - 200Gbps + ...