From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 0D1D0B381 for ; Mon, 25 Aug 2014 08:09:53 +0200 (CEST) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 24 Aug 2014 23:13:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="376517155" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by FMSMGA003.fm.intel.com with ESMTP; 24 Aug 2014 23:09:42 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s7P6Dipo012323; Mon, 25 Aug 2014 14:13:44 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s7P6De7J011410; Mon, 25 Aug 2014 14:13:42 +0800 Received: (from cliang18@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s7P6DeKT011406; Mon, 25 Aug 2014 14:13:40 +0800 From: Cunming Liang To: dev@dpdk.org Date: Mon, 25 Aug 2014 14:12:54 +0800 Message-Id: <1408947174-11323-6-git-send-email-cunming.liang@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1408947174-11323-1-git-send-email-cunming.liang@intel.com> References: <1408947174-11323-1-git-send-email-cunming.liang@intel.com> Subject: [dpdk-dev] [PATCH 5/5] app/test: allow to create packets in different sizes X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Aug 2014 06:09:54 -0000 adding support to allow packet burst generator to create packets of differenct sizes Signed-off-by: Cunming Liang Acked-by: Declan Doherty --- app/test/packet_burst_generator.c | 26 +++++++++----------------- app/test/packet_burst_generator.h | 11 ++++++++--- app/test/test_link_bonding.c | 39 ++++++++++++++++++++++++++------------- app/test/test_pmd_perf.c | 3 ++- 4 files changed, 45 insertions(+), 34 deletions(-) diff --git a/app/test/packet_burst_generator.c b/app/test/packet_burst_generator.c index 943ea98..bf78362 100644 --- a/app/test/packet_burst_generator.c +++ b/app/test/packet_burst_generator.c @@ -190,20 +190,12 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t src_addr, */ #define RTE_MAX_SEGS_PER_PKT 255 /**< pkt.nb_segs is a 8-bit unsigned char. */ -#define TXONLY_DEF_PACKET_LEN 60 -#define TXONLY_DEF_PACKET_LEN_128 128 - -uint16_t tx_pkt_length = TXONLY_DEF_PACKET_LEN; -uint16_t tx_pkt_seg_lengths[RTE_MAX_SEGS_PER_PKT] = { - TXONLY_DEF_PACKET_LEN, -}; - -uint8_t tx_pkt_nb_segs = 1; - int generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst, - struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr, - uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst) + struct ether_hdr *eth_hdr, uint8_t vlan_enabled, + void *ip_hdr, uint8_t ipv4, struct udp_hdr *udp_hdr, + int nb_pkt_per_burst, uint8_t pkt_len, + uint8_t nb_pkt_segs) { int i, nb_pkt = 0; size_t eth_hdr_size; @@ -220,9 +212,9 @@ nomore_mbuf: break; } - pkt->pkt.data_len = tx_pkt_seg_lengths[0]; + pkt->pkt.data_len = pkt_len; pkt_seg = pkt; - for (i = 1; i < tx_pkt_nb_segs; i++) { + for (i = 1; i < nb_pkt_segs; i++) { pkt_seg->pkt.next = rte_pktmbuf_alloc(mp); if (pkt_seg->pkt.next == NULL) { pkt->pkt.nb_segs = i; @@ -230,7 +222,7 @@ nomore_mbuf: goto nomore_mbuf; } pkt_seg = pkt_seg->pkt.next; - pkt_seg->pkt.data_len = tx_pkt_seg_lengths[i]; + pkt_seg->pkt.data_len = pkt_len; } pkt_seg->pkt.next = NULL; /* Last segment of packet. */ @@ -258,8 +250,8 @@ nomore_mbuf: * Complete first mbuf of packet and append it to the * burst of packets to be transmitted. */ - pkt->pkt.nb_segs = tx_pkt_nb_segs; - pkt->pkt.pkt_len = tx_pkt_length; + pkt->pkt.nb_segs = nb_pkt_segs; + pkt->pkt.pkt_len = pkt_len; pkt->pkt.vlan_macip.f.l2_len = eth_hdr_size; if (ipv4) { diff --git a/app/test/packet_burst_generator.h b/app/test/packet_burst_generator.h index 5b3cd6c..fe992ac 100644 --- a/app/test/packet_burst_generator.h +++ b/app/test/packet_burst_generator.h @@ -47,10 +47,13 @@ extern "C" { #define IPV4_ADDR(a, b, c, d)(((a & 0xff) << 24) | ((b & 0xff) << 16) | \ ((c & 0xff) << 8) | (d & 0xff)) +#define PACKET_BURST_GEN_PKT_LEN 60 +#define PACKET_BURST_GEN_PKT_LEN_128 128 void initialize_eth_header(struct ether_hdr *eth_hdr, struct ether_addr *src_mac, - struct ether_addr *dst_mac, uint8_t vlan_enabled, uint16_t van_id); + struct ether_addr *dst_mac, uint8_t vlan_enabled, + uint16_t van_id); uint16_t initialize_udp_header(struct udp_hdr *udp_hdr, uint16_t src_port, @@ -67,8 +70,10 @@ initialize_ipv4_header(struct ipv4_hdr *ip_hdr, uint32_t src_addr, int generate_packet_burst(struct rte_mempool *mp, struct rte_mbuf **pkts_burst, - struct ether_hdr *eth_hdr, uint8_t vlan_enabled, void *ip_hdr, - uint8_t ipv4, struct udp_hdr *udp_hdr, int nb_pkt_per_burst); + struct ether_hdr *eth_hdr, uint8_t vlan_enabled, + void *ip_hdr, uint8_t ipv4, struct udp_hdr *udp_hdr, + int nb_pkt_per_burst, uint8_t pkt_len, + uint8_t nb_pkt_segs); #ifdef __cplusplus } diff --git a/app/test/test_link_bonding.c b/app/test/test_link_bonding.c index 5c1303e..758f1b1 100644 --- a/app/test/test_link_bonding.c +++ b/app/test/test_link_bonding.c @@ -1189,9 +1189,12 @@ generate_test_burst(struct rte_mbuf **pkts_burst, uint16_t burst_size, } /* Generate burst of packets to transmit */ - generated_burst_size = generate_packet_burst(test_params->mbuf_pool, - pkts_burst, test_params->pkt_eth_hdr, vlan, ip_hdr, ipv4, - test_params->pkt_udp_hdr, burst_size); + generated_burst_size = + generate_packet_burst(test_params->mbuf_pool, + pkts_burst, test_params->pkt_eth_hdr, + vlan, ip_hdr, ipv4, + test_params->pkt_udp_hdr, burst_size, + PACKET_BURST_GEN_PKT_LEN_128, 1); if (generated_burst_size != burst_size) { printf("Failed to generate packet burst"); return -1; @@ -1778,9 +1781,12 @@ test_activebackup_tx_burst(void) } /* Generate a burst of packets to transmit */ - generated_burst_size = generate_packet_burst(test_params->mbuf_pool, - pkts_burst, test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, - 1, test_params->pkt_udp_hdr, burst_size); + generated_burst_size = + generate_packet_burst(test_params->mbuf_pool, + pkts_burst, test_params->pkt_eth_hdr, 0, + test_params->pkt_ipv4_hdr, 1, + test_params->pkt_udp_hdr, burst_size, + PACKET_BURST_GEN_PKT_LEN, 1); if (generated_burst_size != burst_size) return -1; @@ -2432,8 +2438,10 @@ test_balance_l2_tx_burst(void) /* Generate a burst 1 of packets to transmit */ if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[0][0], - test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1, - test_params->pkt_udp_hdr, burst_size[0]) != burst_size[0]) + test_params->pkt_eth_hdr, 0, + test_params->pkt_ipv4_hdr, 1, + test_params->pkt_udp_hdr, burst_size[0], + PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[0]) return -1; initialize_eth_header(test_params->pkt_eth_hdr, @@ -2441,8 +2449,10 @@ test_balance_l2_tx_burst(void) /* Generate a burst 2 of packets to transmit */ if (generate_packet_burst(test_params->mbuf_pool, &pkts_burst[1][0], - test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, 1, - test_params->pkt_udp_hdr, burst_size[1]) != burst_size[1]) + test_params->pkt_eth_hdr, 0, + test_params->pkt_ipv4_hdr, 1, + test_params->pkt_udp_hdr, burst_size[1], + PACKET_BURST_GEN_PKT_LEN, 1) != burst_size[1]) return -1; /* Send burst 1 on bonded port */ @@ -3259,9 +3269,12 @@ test_broadcast_tx_burst(void) } /* Generate a burst of packets to transmit */ - generated_burst_size = generate_packet_burst(test_params->mbuf_pool, - pkts_burst, test_params->pkt_eth_hdr, 0, test_params->pkt_ipv4_hdr, - 1, test_params->pkt_udp_hdr, burst_size); + generated_burst_size = + generate_packet_burst(test_params->mbuf_pool, + pkts_burst, test_params->pkt_eth_hdr, 0, + test_params->pkt_ipv4_hdr, 1, + test_params->pkt_udp_hdr, burst_size, + PACKET_BURST_GEN_PKT_LEN, 1); if (generated_burst_size != burst_size) return -1; diff --git a/app/test/test_pmd_perf.c b/app/test/test_pmd_perf.c index e11fa41..ea35b38 100644 --- a/app/test/test_pmd_perf.c +++ b/app/test/test_pmd_perf.c @@ -253,7 +253,8 @@ init_traffic(struct rte_mempool *mp, return generate_packet_burst(mp, pkts_burst, &pkt_eth_hdr, 0, &pkt_ipv4_hdr, 1, - &pkt_udp_hdr, burst_size); + &pkt_udp_hdr, burst_size, + PACKET_BURST_GEN_PKT_LEN, 1); } static int -- 1.8.1.4