From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by dpdk.org (Postfix) with ESMTP id 279DC1E379 for ; Mon, 11 Jun 2018 20:25:34 +0200 (CEST) Received: by mail-pf0-f193.google.com with SMTP id y8-v6so1606731pfm.10 for ; Mon, 11 Jun 2018 11:25:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=t2FjeMIpY9tCm1bYZjQwIp5dZ0qUnAxWGPr/dxWUNZk=; b=uv5JVKzwgAKS7LQYd1MOUrBwmIzN9fNqonOUVh3iGaAgU2gaDT5sYD8vetENk5mGyh 4KtKq6q0AW8HZ7b0Wz/lh8Z7mJo4m06IF23ETgBNXb+fiG42oOobNRDnYy7ei3vy3hqK vBqOvT+gi97XDe9N7ZDMcbaU4dE7ddqTwOi5XyRf2cz0rYsiAu6pVv0CB0Aclyte4xnU fIcLV5mngm0M/Ukz51uQV7cnVt5A3KDjkMW9lTix4pl7IN8rVTKNlCgiT+a0OJOKij3G MCPQi//e/MymndOYi+13o03mo3kcf4Xbkq8B9fVY+fKRMbritRWKWIUq1hbbIkB9+wSW t2Vg== 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; bh=t2FjeMIpY9tCm1bYZjQwIp5dZ0qUnAxWGPr/dxWUNZk=; b=qH0IQjVnA1vnPYE7hVZszt694hDYZQcJy3O1NGO4IWBeIe3CfuejfHUWWdd6ZZzGSI 56It0iEmHN5WbSmdPT9yveMRn8OjbtBJtr8h6Aceao2bkkLvU8mxrILcypWvrjvJ/Ehk Mq/Jf8t12zu+eWknK2M3tDp5v2VY+fI8t1Zs9s1Rhpnf1oIT5EJgOnOen0HvPMU2InEh QNuIbFGGZ9h5qsXkQYqbjV0yHqCqobOraFHHfQw4tKOa9qlUGGGUkc7Av/QyyvQCXo3x Vai8o9URpabRkm6D9ffJZCK3OqWaCa0rPuW9gKEl7SpdhnCMmoqwX8u7CRNwO7+tKWt4 wkJg== X-Gm-Message-State: APt69E09qB9NLEAWkgG+NRwUY8b4vZ+x18CijyRf26HYrfIakh9HpkJo 2dWZSPo09/bUYF8POYth7CHJLuxfPqI= X-Google-Smtp-Source: ADUXVKJiko9ka95ztc2t08MLn3JqzN/9PaSMjAYv8fReqrGOfm9aSdp16D05GYscIOZ6ab/k9kbKoQ== X-Received: by 2002:a62:9e88:: with SMTP id f8-v6mr305113pfk.206.1528741533067; Mon, 11 Jun 2018 11:25:33 -0700 (PDT) Received: from xeon-e3.lan (204-195-35-107.wavecable.com. [204.195.35.107]) by smtp.gmail.com with ESMTPSA id g2-v6sm2982041pfc.4.2018.06.11.11.25.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Jun 2018 11:25:31 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Mon, 11 Jun 2018 11:25:26 -0700 Message-Id: <20180611182526.32327-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180611182526.32327-1-stephen@networkplumber.org> References: <20180611182526.32327-1-stephen@networkplumber.org> Subject: [dpdk-dev] [PATCH v2 2/2] testpmd: add ability to set tx IP and UDP parameters 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: , X-List-Received-Date: Mon, 11 Jun 2018 18:25:34 -0000 Allow user to override the hard coded IP address and UDP port values in Tx only test. Signed-off-by: Stephen Hemminger --- app/test-pmd/parameters.c | 49 +++++++++++++++++++++++++++ app/test-pmd/testpmd.h | 6 ++++ app/test-pmd/txonly.c | 16 ++++----- doc/guides/testpmd_app_ug/run_app.rst | 9 +++++ 4 files changed, 72 insertions(+), 8 deletions(-) diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 75807623c719..6d666e088fd9 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -65,6 +66,7 @@ usage(char* progname) #ifdef RTE_LIBRTE_CMDLINE "--eth-peers-configfile= | " "--eth-peer=X,M:M:M:M:M:M | " + "--tx-ip=SRC,DST | --tx-udp=PORT | " #endif "--pkt-filter-mode= |" "--rss-ip | --rss-udp | " @@ -625,6 +627,8 @@ launch_args_parse(int argc, char** argv) { "vxlan-gpe-port", 1, 0, 0 }, { "mlockall", 0, 0, 0 }, { "no-mlockall", 0, 0, 0 }, + { "tx-ip", 1, 0, 0 }, + { "tx-udp", 1, 0, 0 }, { 0, 0, 0, 0 }, }; @@ -717,6 +721,51 @@ launch_args_parse(int argc, char** argv) nb_peer_eth_addrs++; } #endif + if (!strcmp(lgopts[opt_idx].name, "tx-ip")) { + struct in_addr in; + char *end; + + end = strchr(optarg, ','); + if (end == optarg || !end) + rte_exit(EXIT_FAILURE, + "Invalid tx-ip: %s", optarg); + + *end++ = 0; + if (inet_aton(optarg, &in) == 0) + rte_exit(EXIT_FAILURE, + "Invalid source IP address: %s\n", optarg); + tx_ip_src_addr = rte_be_to_cpu_32(in.s_addr); + + if (inet_aton(end, &in) == 0) + rte_exit(EXIT_FAILURE, + "Invalid destination IP address: %s\n", optarg); + tx_ip_dst_addr = rte_be_to_cpu_32(in.s_addr); + } + if (!strcmp(lgopts[opt_idx].name, "tx-udp")) { + char *end = NULL; + + errno = 0; + n = strtoul(optarg, &end, 10); + if (errno != 0 || end == optarg || n > UINT16_MAX || + !(*end == '\0' || *end == ',')) + rte_exit(EXIT_FAILURE, + "Invalid UDP port: %s\n", optarg); + tx_udp_src_port = n; + if (*end == ',') { + char *dst = end + 1; + + n = strtoul(dst, &end, 10); + if (errno != 0 || end == dst || + n > UINT16_MAX || *end) + rte_exit(EXIT_FAILURE, + "Invalid destination UDP port: %s\n", + dst); + tx_udp_dst_port = n; + } else { + tx_udp_dst_port = n; + } + + } if (!strcmp(lgopts[opt_idx].name, "nb-ports")) { n = atoi(optarg); if (n > 0 && n <= nb_ports) diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index f51cd9dd9bbd..48f7b364e9b3 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -444,6 +444,12 @@ extern int8_t tx_pthresh; extern int8_t tx_hthresh; extern int8_t tx_wthresh; +extern uint16_t tx_udp_src_port; +extern uint16_t tx_udp_dst_port; + +extern uint32_t tx_ip_src_addr; +extern uint32_t tx_ip_dst_addr; + extern struct fwd_config cur_fwd_config; extern struct fwd_engine *cur_fwd_eng; extern uint32_t retry_enabled; diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index a24000e3af44..6d7ddf99d639 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -41,12 +41,12 @@ #include "testpmd.h" /* RFC863 discard port */ -#define UDP_SRC_PORT 9 -#define UDP_DST_PORT 9 +uint16_t tx_udp_src_port = 9; +uint16_t tx_udp_dst_port = 9; /* RFC2544 reserved test subnet 192.18.0.0 */ -#define IP_SRC_ADDR ((192U << 24) | (18 << 16) | (0 << 8) | 1) -#define IP_DST_ADDR ((192U << 24) | (18 << 16) | (0 << 8) | 2) +uint32_t tx_ip_src_addr = (192U << 24) | (18 << 16) | (0 << 8) | 1; +uint32_t tx_ip_dst_addr = (192U << 24) | (18 << 16) | (0 << 8) | 2; #define IP_DEFTTL 64 /* from RFC 1340. */ #define IP_VERSION 0x40 @@ -106,8 +106,8 @@ setup_pkt_udp_ip_headers(struct ipv4_hdr *ip_hdr, * Initialize UDP header. */ pkt_len = (uint16_t) (pkt_data_len + sizeof(struct udp_hdr)); - udp_hdr->src_port = rte_cpu_to_be_16(UDP_SRC_PORT); - udp_hdr->dst_port = rte_cpu_to_be_16(UDP_DST_PORT); + udp_hdr->src_port = rte_cpu_to_be_16(tx_udp_src_port); + udp_hdr->dst_port = rte_cpu_to_be_16(tx_udp_dst_port); udp_hdr->dgram_len = RTE_CPU_TO_BE_16(pkt_len); udp_hdr->dgram_cksum = 0; /* No UDP checksum. */ @@ -122,8 +122,8 @@ setup_pkt_udp_ip_headers(struct ipv4_hdr *ip_hdr, ip_hdr->next_proto_id = IPPROTO_UDP; ip_hdr->packet_id = 0; ip_hdr->total_length = RTE_CPU_TO_BE_16(pkt_len); - ip_hdr->src_addr = rte_cpu_to_be_32(IP_SRC_ADDR); - ip_hdr->dst_addr = rte_cpu_to_be_32(IP_DST_ADDR); + ip_hdr->src_addr = rte_cpu_to_be_32(tx_ip_src_addr); + ip_hdr->dst_addr = rte_cpu_to_be_32(tx_ip_dst_addr); /* * Compute IP header checksum. diff --git a/doc/guides/testpmd_app_ug/run_app.rst b/doc/guides/testpmd_app_ug/run_app.rst index f301c2b6f709..ae9eb712e209 100644 --- a/doc/guides/testpmd_app_ug/run_app.rst +++ b/doc/guides/testpmd_app_ug/run_app.rst @@ -249,6 +249,15 @@ The commandline options are: Set the MAC address ``XX:XX:XX:XX:XX:XX`` of the peer port N, where 0 <= N < ``CONFIG_RTE_MAX_ETHPORTS`` from the configuration file. + +* ``--tx-ip=SRC,DST`` + Set the source and destination IP address used when doing transmit only test. + The defaults are source 192.18.0.1 and destination 192.18.0.2. + +* ``--tx-udp=SRC[,DST]`` + Set the source and destination UDP port number for transmit test only test. + The default port is the 9 (discard). + * ``--pkt-filter-mode=mode`` Set Flow Director mode where mode is either ``none`` (the default), ``signature`` or ``perfect``. -- 2.17.1