From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 92D4A4291F; Tue, 11 Apr 2023 22:17:51 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2DAAE40E2D; Tue, 11 Apr 2023 22:17:51 +0200 (CEST) Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by mails.dpdk.org (Postfix) with ESMTP id 3970D40DFD for ; Tue, 11 Apr 2023 22:17:50 +0200 (CEST) Received: by mail-yb1-f202.google.com with SMTP id u188-20020a2560c5000000b00b8f15f2111dso4582184ybb.4 for ; Tue, 11 Apr 2023 13:17:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681244269; x=1683836269; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=esEhxsXs4fJhSO3BsNTuht+remKOWEk/5gK2Kp1X5jM=; b=74MN4pUU8LAdvFu5MOJlzln0JuxLcajkqanMIA1bZYPipffyz2238O1JjbSd8D+cGD sAgY1Q8QuuWdLRLTX8Bl9Q4NxDrhYjsMwhk4JDSFqlmx4+T2Kqm8cLzP6QOECQzgxCcg SUAfdrKu6OYmxe2OHyLGKikAll1L7YoKlqpBcTInYivDLiwvPiGneGBZ8GUedINofch4 aC56xlz7ZY9rvqXctmfpRCoGfjGnOtP68MJ7mVNEq7Hx4j2p+2iKDtEzh/t1eaSfikJx wIFsj6tsB7HGc/50/yaVZs8tjV4rb/VvdgGJsjugTCyG6jLTjr2P4Db+uHrcTwWZkdTE fjzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681244269; x=1683836269; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=esEhxsXs4fJhSO3BsNTuht+remKOWEk/5gK2Kp1X5jM=; b=yDGu9MUef8ddGOtM/HNgx15Qr0rF+JJaBSjgzUMUJzISsjODwPdPMu6KkFZ2Cz8cnT OQYJTJpV85kuw8Cfes5cONjQRH4VewtUFrjCrUFiZ8b868YdcHO3FaFHSdFQmNxAMN7h md9ZBblJh0zZjS+dPKE2cTqVy5T9i9zdAf7rlKoXg9Z2H1fx2oSNZCmNcJwxeEtzQkPq XiNClzI/N+3BQEvBQ0qMtHD0aWhZ1iLnIlZXei4+KV76QRQOrI/OLh7GpyI72VL2J62U SZ5tn9R4YxgbEfdDaUUHU0fjR+8i8MMdnwZjtSKDGQz0wlMigroMCZQ8Zdfu1F0un2eV 6bLQ== X-Gm-Message-State: AAQBX9fzP7ozMrI1gGWpesmeFOLgG9W66/P1GX6UcH6N8JBqS99kAYue XLjs7l9LBNk5fPTEeYoUSCEVq6pzluYnQA== X-Google-Smtp-Source: AKy350YJIrwjE0U0JLut5I6mlJ6kwxsdFVua1s+OJCz7pPZPR1LmQzAfrakCZIyPlHPN57/o6ZtbG6TfV5vpOw== X-Received: from joshwash.sea.corp.google.com ([2620:15c:100:202:ff59:cc9c:409c:ce3d]) (user=joshwash job=sendgmr) by 2002:a81:af4e:0:b0:52f:184a:da09 with SMTP id x14-20020a81af4e000000b0052f184ada09mr313390ywj.2.1681244269600; Tue, 11 Apr 2023 13:17:49 -0700 (PDT) Date: Tue, 11 Apr 2023 13:17:41 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.40.0.577.gac1e443424-goog Message-ID: <20230411201741.2806769-1-joshwash@google.com> Subject: [PATCH v2] app/testpmd: txonly multiflow port change support From: Joshua Washington To: Aman Singh , Yuying Zhang Cc: dev@dpdk.org, Joshua Washington , Rushil Gupta Content-Type: text/plain; charset="UTF-8" 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 Google cloud routes traffic using IP addresses without the support of MAC addresses, so changing source IP address for txonly-multi-flow can have negative performance implications for net/gve when using testpmd. This change adds a new flag --txonly-alter-port, which allows the alteration of source port instead of source IP address for txonly multiflow mode. The new flag can be tested with the following command: dpdk-testpmd -- --forward-mode=txonly --txonly-multi-flow \ --txonly-alter-port --txip=, Signed-off-by: Joshua Washington Reviewed-by: Rushil Gupta --- app/test-pmd/parameters.c | 4 +++ app/test-pmd/testpmd.c | 6 ++++ app/test-pmd/testpmd.h | 1 + app/test-pmd/txonly.c | 51 ++++++++++++++++++--------- doc/guides/testpmd_app_ug/run_app.rst | 6 ++++ 5 files changed, 52 insertions(+), 16 deletions(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 3b37809baf..a99f04b4f0 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -158,6 +158,7 @@ usage(char* progname) " or total packet length.\n"); printf(" --multi-rx-mempool: enable multi-rx-mempool support\n"); printf(" --txonly-multi-flow: generate multiple flows in txonly mode\n"); + printf(" --txonly-alter-port: alter source port when generating multiple flows in txonly mode. Source IP address is changed by default\n"); printf(" --tx-ip=src,dst: IP addresses in Tx-only mode\n"); printf(" --tx-udp=src[,dst]: UDP ports in Tx-only mode\n"); printf(" --eth-link-speed: force link speed.\n"); @@ -678,6 +679,7 @@ launch_args_parse(int argc, char** argv) { "txpkts", 1, 0, 0 }, { "multi-rx-mempool", 0, 0, 0 }, { "txonly-multi-flow", 0, 0, 0 }, + { "txonly-alter-port", 0, 0, 0 }, { "rxq-share", 2, 0, 0 }, { "eth-link-speed", 1, 0, 0 }, { "disable-link-check", 0, 0, 0 }, @@ -1307,6 +1309,8 @@ launch_args_parse(int argc, char** argv) multi_rx_mempool = 1; if (!strcmp(lgopts[opt_idx].name, "txonly-multi-flow")) txonly_multi_flow = 1; + if (!strcmp(lgopts[opt_idx].name, "txonly-alter-port")) + txonly_alter_port = 1; if (!strcmp(lgopts[opt_idx].name, "rxq-share")) { if (optarg == NULL) { rxq_share = UINT32_MAX; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 5cb6f92523..b78bc4c26d 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -267,6 +267,12 @@ enum tx_pkt_split tx_pkt_split = TX_PKT_SPLIT_OFF; uint8_t txonly_multi_flow; /**< Whether multiple flows are generated in TXONLY mode. */ +uint8_t txonly_alter_port; +/* + * Whether source port should be altered instead of IP address when generating + * multiple flows in TXONLY mode. + */ + uint32_t tx_pkt_times_inter; /**< Timings for send scheduling in TXONLY mode, time between bursts. */ diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index bdfbfd36d3..8926b51595 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -619,6 +619,7 @@ enum tx_pkt_split { extern enum tx_pkt_split tx_pkt_split; extern uint8_t txonly_multi_flow; +extern uint8_t txonly_alter_port; extern uint32_t rxq_share; diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index b3d6873104..58b8834f08 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -56,7 +56,7 @@ uint32_t tx_ip_dst_addr = (198U << 24) | (18 << 16) | (0 << 8) | 2; #define IP_DEFTTL 64 /* from RFC 1340. */ static struct rte_ipv4_hdr pkt_ip_hdr; /**< IP header of transmitted packets. */ -RTE_DEFINE_PER_LCORE(uint8_t, _ip_var); /**< IP address variation */ +RTE_DEFINE_PER_LCORE(uint16_t, _src_var); /**< Source address/port variation */ static struct rte_udp_hdr pkt_udp_hdr; /**< UDP header of tx packets. */ static uint64_t timestamp_mask; /**< Timestamp dynamic flag mask */ @@ -230,28 +230,47 @@ pkt_burst_prepare(struct rte_mbuf *pkt, struct rte_mempool *mbp, copy_buf_to_pkt(eth_hdr, sizeof(*eth_hdr), pkt, 0); copy_buf_to_pkt(&pkt_ip_hdr, sizeof(pkt_ip_hdr), pkt, sizeof(struct rte_ether_hdr)); + copy_buf_to_pkt(&pkt_udp_hdr, sizeof(pkt_udp_hdr), pkt, + sizeof(struct rte_ether_hdr) + + sizeof(struct rte_ipv4_hdr)); if (txonly_multi_flow) { - uint8_t ip_var = RTE_PER_LCORE(_ip_var); - struct rte_ipv4_hdr *ip_hdr; - uint32_t addr; + uint16_t src_var = RTE_PER_LCORE(_src_var); - ip_hdr = rte_pktmbuf_mtod_offset(pkt, - struct rte_ipv4_hdr *, - sizeof(struct rte_ether_hdr)); /* - * Generate multiple flows by varying IP src addr. This - * enables packets are well distributed by RSS in + * Generate multiple flows by varying IP source address/port. + * This enables packets are well distributed by RSS in * receiver side if any and txonly mode can be a decent * packet generator for developer's quick performance * regression test. */ - addr = (tx_ip_dst_addr | (ip_var++ << 8)) + rte_lcore_id(); - ip_hdr->src_addr = rte_cpu_to_be_32(addr); - RTE_PER_LCORE(_ip_var) = ip_var; + if (txonly_alter_port) { + struct rte_udp_hdr *udp_hdr; + uint16_t port; + + udp_hdr = rte_pktmbuf_mtod_offset(pkt, + struct rte_udp_hdr *, + sizeof(struct rte_ether_hdr) + + sizeof(struct rte_ipv4_hdr)); + /* + * Vary source port. + */ + port = src_var++; + udp_hdr->src_port = rte_cpu_to_be_16(port); + } else { + struct rte_ipv4_hdr *ip_hdr; + uint32_t addr; + + ip_hdr = rte_pktmbuf_mtod_offset(pkt, + struct rte_ipv4_hdr *, + sizeof(struct rte_ether_hdr)); + /* + * Vary IP source address. + */ + addr = (tx_ip_dst_addr | ((src_var++ & 0xFF) << 8)) + rte_lcore_id(); + ip_hdr->src_addr = rte_cpu_to_be_32(addr); + } + RTE_PER_LCORE(_src_var) = src_var; } - copy_buf_to_pkt(&pkt_udp_hdr, sizeof(pkt_udp_hdr), pkt, - sizeof(struct rte_ether_hdr) + - sizeof(struct rte_ipv4_hdr)); if (unlikely(tx_pkt_split == TX_PKT_SPLIT_RND) || txonly_multi_flow) update_pkt_header(pkt, pkt_len); @@ -393,7 +412,7 @@ pkt_burst_transmit(struct fwd_stream *fs) nb_tx = common_fwd_stream_transmit(fs, pkts_burst, nb_pkt); if (txonly_multi_flow) - RTE_PER_LCORE(_ip_var) -= nb_pkt - nb_tx; + RTE_PER_LCORE(_src_var) -= nb_pkt - nb_tx; if (unlikely(nb_tx < nb_pkt)) { if (verbose_level > 0 && fs->fwd_dropped == 0) diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index 57b23241cf..89fac9e964 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -373,6 +373,12 @@ The command line options are: Generate multiple flows in txonly mode. +* ``--txonly-alter-port`` + + Alter source port when generating multiple flows in txonly mode. The default + behavior is to alter source IP address. This flag must be used in + conjunction with --txonly-multi-flow. + * ``--rxq-share=[X]`` Create queues in shared Rx queue mode if device supports. -- 2.40.0.577.gac1e443424-goog