From patchwork Thu Sep 26 06:29:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ori Kam X-Patchwork-Id: 59787 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 197891BEA6; Thu, 26 Sep 2019 08:30:18 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 596551B994 for ; Thu, 26 Sep 2019 08:30:05 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from orika@mellanox.com) with ESMTPS (AES256-SHA encrypted); 26 Sep 2019 09:30:00 +0300 Received: from pegasus04.mtr.labs.mlnx. (pegasus04.mtr.labs.mlnx [10.210.16.126]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id x8Q6TmlL012493; Thu, 26 Sep 2019 09:30:00 +0300 From: Ori Kam To: Wenzhuo Lu , Jingjing Wu , Bernard Iremonger Cc: dev@dpdk.org, orika@mellanox.com, stephen@networkplumber.org Date: Thu, 26 Sep 2019 06:29:02 +0000 Message-Id: <1569479349-36962-7-git-send-email-orika@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1569479349-36962-1-git-send-email-orika@mellanox.com> References: <1569479349-36962-1-git-send-email-orika@mellanox.com> Subject: [dpdk-dev] [PATCH 06/13] app/testpmd: add hairpin support 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 commit introduce the hairpin queues to the testpmd. the hairpin queue is configured using --hairpinq= the hairpin queue adds n queue objects for both the total number of TX queues and RX queues. The connection between the queues are 1 to 1, first Rx hairpin queue will be connected to the first Tx hairpin queue Signed-off-by: Ori Kam Acked-by: Viacheslav Ovsiienko --- app/test-pmd/parameters.c | 12 ++++++++++ app/test-pmd/testpmd.c | 59 +++++++++++++++++++++++++++++++++++++++++++++-- app/test-pmd/testpmd.h | 1 + 3 files changed, 70 insertions(+), 2 deletions(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 6c78dca..16bdcc8 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -147,6 +147,8 @@ printf(" --rxd=N: set the number of descriptors in RX rings to N.\n"); printf(" --txq=N: set the number of TX queues per port to N.\n"); printf(" --txd=N: set the number of descriptors in TX rings to N.\n"); + printf(" --hairpinq=N: set the number of hairpin queues per port to " + "N.\n"); printf(" --burst=N: set the number of packets per burst to N.\n"); printf(" --mbcache=N: set the cache of mbuf memory pool to N.\n"); printf(" --rxpt=N: set prefetch threshold register of RX rings to N.\n"); @@ -618,6 +620,7 @@ { "txq", 1, 0, 0 }, { "rxd", 1, 0, 0 }, { "txd", 1, 0, 0 }, + { "hairpinq", 1, 0, 0 }, { "burst", 1, 0, 0 }, { "mbcache", 1, 0, 0 }, { "txpt", 1, 0, 0 }, @@ -1036,6 +1039,15 @@ " >= 0 && <= %u\n", n, get_allowed_max_nb_txq(&pid)); } + if (!strcmp(lgopts[opt_idx].name, "hairpinq")) { + n = atoi(optarg); + if (n >= 0 && check_nb_txq((queueid_t)n) == 0) + nb_hairpinq = (queueid_t) n; + else + rte_exit(EXIT_FAILURE, "txq %d invalid - must be" + " >= 0 && <= %u\n", n, + get_allowed_max_nb_txq(&pid)); + } if (!nb_rxq && !nb_txq) { rte_exit(EXIT_FAILURE, "Either rx or tx queues should " "be non-zero\n"); diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index de91e1b..f15a308 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -235,6 +235,7 @@ struct fwd_engine * fwd_engines[] = { /* * Configurable number of RX/TX queues. */ +queueid_t nb_hairpinq; /**< Number of hairpin queues per port. */ queueid_t nb_rxq = 1; /**< Number of RX queues per port. */ queueid_t nb_txq = 1; /**< Number of TX queues per port. */ @@ -2064,6 +2065,10 @@ struct extmem_param { queueid_t qi; struct rte_port *port; struct rte_ether_addr mac_addr; + struct rte_eth_hairpin_conf hairpin_conf = { + .peer_n = 1, + }; + int i; if (port_id_is_invalid(pid, ENABLED_WARN)) return 0; @@ -2097,8 +2102,9 @@ struct extmem_param { printf("Configuring Port %d (socket %u)\n", pi, port->socket_id); /* configure port */ - diag = rte_eth_dev_configure(pi, nb_rxq, nb_txq, - &(port->dev_conf)); + diag = rte_eth_dev_configure(pi, nb_rxq + nb_hairpinq, + nb_txq + nb_hairpinq, + &(port->dev_conf)); if (diag != 0) { if (rte_atomic16_cmpset(&(port->port_status), RTE_PORT_HANDLING, RTE_PORT_STOPPED) == 0) @@ -2191,6 +2197,55 @@ struct extmem_param { port->need_reconfig_queues = 1; return -1; } + /* setup hairpin queues */ + i = 0; + for (qi = nb_txq; qi < nb_hairpinq + nb_txq; qi++) { + hairpin_conf.peers[0].port = pi; + hairpin_conf.peers[0].queue = i + nb_rxq; + diag = rte_eth_tx_hairpin_queue_setup + (pi, qi, nb_txd, + port->socket_id, &(port->tx_conf[qi]), + &hairpin_conf); + i++; + if (diag == 0) + continue; + + /* Fail to setup rx queue, return */ + if (rte_atomic16_cmpset(&(port->port_status), + RTE_PORT_HANDLING, + RTE_PORT_STOPPED) == 0) + printf("Port %d can not be set back " + "to stopped\n", pi); + printf("Fail to configure port %d hairpin " + "queues\n", pi); + /* try to reconfigure queues next time */ + port->need_reconfig_queues = 1; + return -1; + } + i = 0; + for (qi = nb_rxq; qi < nb_hairpinq + nb_rxq; qi++) { + hairpin_conf.peers[0].port = pi; + hairpin_conf.peers[0].queue = i + nb_txq; + diag = rte_eth_rx_hairpin_queue_setup + (pi, qi, nb_rxd, + port->socket_id, &(port->rx_conf[qi]), + &hairpin_conf); + i++; + if (diag == 0) + continue; + + /* Fail to setup rx queue, return */ + if (rte_atomic16_cmpset(&(port->port_status), + RTE_PORT_HANDLING, + RTE_PORT_STOPPED) == 0) + printf("Port %d can not be set back " + "to stopped\n", pi); + printf("Fail to configure port %d hairpin " + "queues\n", pi); + /* try to reconfigure queues next time */ + port->need_reconfig_queues = 1; + return -1; + } } configure_rxtx_dump_callbacks(verbose_level); /* start port */ diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index d73955d..09baa72 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -383,6 +383,7 @@ struct queue_stats_mappings { extern uint64_t rss_hf; +extern queueid_t nb_hairpinq; extern queueid_t nb_rxq; extern queueid_t nb_txq;