[dpdk-dev] app/testpmd: make txonly mode generate multiple flows

Message ID 20171215211125.39177-1-yskoh@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Yongseok Koh Dec. 15, 2017, 9:11 p.m. UTC
  Testpmd can generate multiple flows without taking much cost and this could
be a simple traffic generator for developer's quick tests. IP destination
address is varied.

Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
---
 app/test-pmd/txonly.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)
  

Comments

Thomas Monjalon Jan. 12, 2018, 6:08 p.m. UTC | #1
+Cc Wenzhuo

Wenzhuo, please could you check this list?
	https://dpdk.org/dev/patchwork/project/dpdk/list/?q=testpmd
Thanks a lot

15/12/2017 22:11, Yongseok Koh:
> Testpmd can generate multiple flows without taking much cost and this could
> be a simple traffic generator for developer's quick tests. IP destination
> address is varied.
> 
> Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
  
Wenzhuo Lu Jan. 16, 2018, 2:40 a.m. UTC | #2
Hi Yongseok,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Yongseok Koh
> Sent: Saturday, December 16, 2017 5:11 AM
> To: Wu, Jingjing <jingjing.wu@intel.com>
> Cc: dev@dpdk.org; Yongseok Koh <yskoh@mellanox.com>
> Subject: [dpdk-dev] [PATCH] app/testpmd: make txonly mode generate
> multiple flows
> 
> Testpmd can generate multiple flows without taking much cost and this
> could be a simple traffic generator for developer's quick tests. IP destination
> address is varied.
> 
> Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
> ---
>  app/test-pmd/txonly.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index
> 309c73893..aa4c379c4 100644
> --- a/app/test-pmd/txonly.c
> +++ b/app/test-pmd/txonly.c
> @@ -73,7 +73,7 @@
>  #define UDP_DST_PORT 1024
> 
>  #define IP_SRC_ADDR ((192U << 24) | (168 << 16) | (0 << 8) | 1) -#define
> IP_DST_ADDR ((192U << 24) | (168 << 16) | (0 << 8) | 2)
> +#define IP_DST_ADDR ((192U << 24) | (168 << 16))
> 
>  #define IP_DEFTTL  64   /* from RFC 1340. */
>  #define IP_VERSION 0x40
> @@ -81,6 +81,7 @@
>  #define IP_VHL_DEF (IP_VERSION | IP_HDRLEN)
> 
>  static struct ipv4_hdr  pkt_ip_hdr;  /**< IP header of transmitted packets. */
> +static __thread uint8_t ip_var; /**< IP address variation */
>  static struct udp_hdr pkt_udp_hdr; /**< UDP header of transmitted packets.
> */
> 
>  static void
> @@ -187,6 +188,7 @@ pkt_burst_transmit(struct fwd_stream *fs)
>  	struct rte_mbuf *pkt_seg;
>  	struct rte_mempool *mbp;
>  	struct ether_hdr eth_hdr;
> +	struct ipv4_hdr *ip_hdr;
>  	uint16_t nb_tx;
>  	uint16_t nb_pkt;
>  	uint16_t vlan_tci, vlan_tci_outer;
> @@ -263,6 +265,14 @@ pkt_burst_transmit(struct fwd_stream *fs)
>  		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 ether_hdr));
> +		ip_hdr = rte_pktmbuf_mtod_offset(pkt, struct ipv4_hdr *,
> +						 sizeof(struct ether_hdr));
> +		/*
> +		 * Generate multiple flows by varying IP dest addr.
> +		 */
> +		ip_hdr->dst_addr =
> +			rte_cpu_to_be_32(IP_DST_ADDR | (ip_var++ << 8) |
> +					 (rte_lcore_id() + 1));
Just curious if we can avoid call rte_lcore_id for every packet?

And suggest to add more explanation here, like purpose, scenario. So when we want to change the behavior, for example, like adding a parameter to make IP addresses configurable, we know what we will break.

>  		copy_buf_to_pkt(&pkt_udp_hdr, sizeof(pkt_udp_hdr), pkt,
>  				sizeof(struct ether_hdr) +
>  				sizeof(struct ipv4_hdr));
> --
> 2.11.0
  
Yongseok Koh Jan. 17, 2018, 6:04 p.m. UTC | #3
> On Jan 15, 2018, at 6:40 PM, Lu, Wenzhuo <wenzhuo.lu@intel.com> wrote:
> 
> Hi Yongseok,
> 
>> -----Original Message-----
>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Yongseok Koh
>> Sent: Saturday, December 16, 2017 5:11 AM
>> To: Wu, Jingjing <jingjing.wu@intel.com>
>> Cc: dev@dpdk.org; Yongseok Koh <yskoh@mellanox.com>
>> Subject: [dpdk-dev] [PATCH] app/testpmd: make txonly mode generate
>> multiple flows
>> 
>> Testpmd can generate multiple flows without taking much cost and this
>> could be a simple traffic generator for developer's quick tests. IP destination
>> address is varied.
>> 
>> Signed-off-by: Yongseok Koh <yskoh@mellanox.com>
>> ---
>> app/test-pmd/txonly.c | 12 +++++++++++-
>> 1 file changed, 11 insertions(+), 1 deletion(-)
>> 
>> diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index
>> 309c73893..aa4c379c4 100644
>> --- a/app/test-pmd/txonly.c
>> +++ b/app/test-pmd/txonly.c
>> @@ -73,7 +73,7 @@
>> #define UDP_DST_PORT 1024
>> 
>> #define IP_SRC_ADDR ((192U << 24) | (168 << 16) | (0 << 8) | 1) -#define
>> IP_DST_ADDR ((192U << 24) | (168 << 16) | (0 << 8) | 2)
>> +#define IP_DST_ADDR ((192U << 24) | (168 << 16))
>> 
>> #define IP_DEFTTL  64   /* from RFC 1340. */
>> #define IP_VERSION 0x40
>> @@ -81,6 +81,7 @@
>> #define IP_VHL_DEF (IP_VERSION | IP_HDRLEN)
>> 
>> static struct ipv4_hdr  pkt_ip_hdr;  /**< IP header of transmitted packets. */
>> +static __thread uint8_t ip_var; /**< IP address variation */
>> static struct udp_hdr pkt_udp_hdr; /**< UDP header of transmitted packets.
>> */
>> 
>> static void
>> @@ -187,6 +188,7 @@ pkt_burst_transmit(struct fwd_stream *fs)
>> 	struct rte_mbuf *pkt_seg;
>> 	struct rte_mempool *mbp;
>> 	struct ether_hdr eth_hdr;
>> +	struct ipv4_hdr *ip_hdr;
>> 	uint16_t nb_tx;
>> 	uint16_t nb_pkt;
>> 	uint16_t vlan_tci, vlan_tci_outer;
>> @@ -263,6 +265,14 @@ pkt_burst_transmit(struct fwd_stream *fs)
>> 		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 ether_hdr));
>> +		ip_hdr = rte_pktmbuf_mtod_offset(pkt, struct ipv4_hdr *,
>> +						 sizeof(struct ether_hdr));
>> +		/*
>> +		 * Generate multiple flows by varying IP dest addr.
>> +		 */
>> +		ip_hdr->dst_addr =
>> +			rte_cpu_to_be_32(IP_DST_ADDR | (ip_var++ << 8) |
>> +					 (rte_lcore_id() + 1));
> Just curious if we can avoid call rte_lcore_id for every packet?

rte_lcore_id() is just to read a per-lcore variable and it is an inline
function, not a real branch. I don't think it has any performance hit.
Actually, I'm using txonly with this patch as a good packet generator to
test development tasks. Mellanox ConnectX-5 can generate 100Gbps @ 64B
(149Mpps) with multiple IP flows.


> And suggest to add more explanation here, like purpose, scenario. So when we want to change the behavior, for example, like adding a parameter to make IP addresses configurable, we know what we will break.

Okay, will add more comment here.

Thanks,
Yongseok
  

Patch

diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c
index 309c73893..aa4c379c4 100644
--- a/app/test-pmd/txonly.c
+++ b/app/test-pmd/txonly.c
@@ -73,7 +73,7 @@ 
 #define UDP_DST_PORT 1024
 
 #define IP_SRC_ADDR ((192U << 24) | (168 << 16) | (0 << 8) | 1)
-#define IP_DST_ADDR ((192U << 24) | (168 << 16) | (0 << 8) | 2)
+#define IP_DST_ADDR ((192U << 24) | (168 << 16))
 
 #define IP_DEFTTL  64   /* from RFC 1340. */
 #define IP_VERSION 0x40
@@ -81,6 +81,7 @@ 
 #define IP_VHL_DEF (IP_VERSION | IP_HDRLEN)
 
 static struct ipv4_hdr  pkt_ip_hdr;  /**< IP header of transmitted packets. */
+static __thread uint8_t ip_var; /**< IP address variation */
 static struct udp_hdr pkt_udp_hdr; /**< UDP header of transmitted packets. */
 
 static void
@@ -187,6 +188,7 @@  pkt_burst_transmit(struct fwd_stream *fs)
 	struct rte_mbuf *pkt_seg;
 	struct rte_mempool *mbp;
 	struct ether_hdr eth_hdr;
+	struct ipv4_hdr *ip_hdr;
 	uint16_t nb_tx;
 	uint16_t nb_pkt;
 	uint16_t vlan_tci, vlan_tci_outer;
@@ -263,6 +265,14 @@  pkt_burst_transmit(struct fwd_stream *fs)
 		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 ether_hdr));
+		ip_hdr = rte_pktmbuf_mtod_offset(pkt, struct ipv4_hdr *,
+						 sizeof(struct ether_hdr));
+		/*
+		 * Generate multiple flows by varying IP dest addr.
+		 */
+		ip_hdr->dst_addr =
+			rte_cpu_to_be_32(IP_DST_ADDR | (ip_var++ << 8) |
+					 (rte_lcore_id() + 1));
 		copy_buf_to_pkt(&pkt_udp_hdr, sizeof(pkt_udp_hdr), pkt,
 				sizeof(struct ether_hdr) +
 				sizeof(struct ipv4_hdr));