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 43E0C7F48 for ; Fri, 7 Nov 2014 11:55:42 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 07 Nov 2014 03:05:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.97,862,1389772800"; d="scan'208";a="412951063" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 07 Nov 2014 02:56:33 -0800 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id sA7B5AaK004953; Fri, 7 Nov 2014 11:05:11 GMT Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id sA7B5AGr013258; Fri, 7 Nov 2014 11:05:10 GMT Received: (from mkjastrx@localhost) by sivswdev01.ir.intel.com with id sA7B5A0u013254; Fri, 7 Nov 2014 11:05:10 GMT From: Michal Jastrzebski To: dev@dpdk.org Date: Fri, 7 Nov 2014 11:04:30 +0000 Message-Id: <1415358270-12523-3-git-send-email-michalx.k.jastrzebski@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1415358270-12523-1-git-send-email-michalx.k.jastrzebski@intel.com> References: <1415358270-12523-1-git-send-email-michalx.k.jastrzebski@intel.com> Subject: [dpdk-dev] [PATCH v3 2/2] test-pmd: add mode 4 support 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: Fri, 07 Nov 2014 10:55:44 -0000 From: Pawel Wodkowski Signed-off-by: Pawel Wodkowski --- app/test-pmd/cmdline.c | 2 ++ app/test-pmd/csumonly.c | 9 ++++++++ app/test-pmd/icmpecho.c | 17 ++++++++++++++- app/test-pmd/iofwd.c | 9 ++++++++ app/test-pmd/macfwd-retry.c | 9 ++++++++ app/test-pmd/macfwd.c | 9 ++++++++ app/test-pmd/macswap.c | 9 ++++++++ app/test-pmd/testpmd.c | 48 +++++++++++++++++++++++++++++++++++++------ app/test-pmd/testpmd.h | 11 ++++++++-- 9 files changed, 114 insertions(+), 9 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index ee8c121..5109cfc 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -3646,6 +3646,8 @@ static void cmd_create_bonded_device_parsed(void *parsed_result, /* Update number of ports */ nb_ports = rte_eth_dev_count(); reconfig(port_id, res->socket); + /* Save bonding mode here as it is constat. */ + ports[port_id].bond_mode = res->mode; rte_eth_promiscuous_enable(port_id); } diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 8d10bfd..c433eea 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -254,8 +254,17 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) */ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); +#ifndef RTE_LIBRTE_PMD_BOND if (unlikely(nb_rx == 0)) return; +#else + if (unlikely(nb_rx == 0 && (fs->forward_timeout == 0 || + fs->next_forward_time > rte_rdtsc()))) + return; + + if (fs->forward_timeout != 0) + fs->next_forward_time = rte_rdtsc() + fs->forward_timeout; +#endif #ifdef RTE_TEST_PMD_RECORD_BURST_STATS fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; diff --git a/app/test-pmd/icmpecho.c b/app/test-pmd/icmpecho.c index 7fd4b6d..e954601 100644 --- a/app/test-pmd/icmpecho.c +++ b/app/test-pmd/icmpecho.c @@ -305,6 +305,9 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) uint16_t arp_pro; uint8_t i; int l2_len; +#if RTE_LIBRTE_PMD_BOND + uint8_t force_tx_burst; +#endif #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES uint64_t start_tsc; uint64_t end_tsc; @@ -320,8 +323,20 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) */ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); +#ifndef RTE_LIBRTE_PMD_BOND if (unlikely(nb_rx == 0)) return; +#else + if (unlikely(nb_rx == 0 && (fs->forward_timeout == 0 || + fs->next_forward_time > rte_rdtsc()))) + return; + + if (fs->forward_timeout != 0) { + force_tx_burst = fs->next_forward_time <= rte_rdtsc(); + fs->next_forward_time = rte_rdtsc() + fs->forward_timeout; + } else + force_tx_burst = 0; +#endif #ifdef RTE_TEST_PMD_RECORD_BURST_STATS fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; @@ -474,7 +489,7 @@ reply_to_icmp_echo_rqsts(struct fwd_stream *fs) } /* Send back ICMP echo replies, if any. */ - if (nb_replies > 0) { + if (nb_replies > 0 || force_tx_burst) { nb_tx = rte_eth_tx_burst(fs->tx_port, fs->tx_queue, pkts_burst, nb_replies); fs->tx_packets += nb_tx; diff --git a/app/test-pmd/iofwd.c b/app/test-pmd/iofwd.c index 02a5977..62a325f 100644 --- a/app/test-pmd/iofwd.c +++ b/app/test-pmd/iofwd.c @@ -96,8 +96,17 @@ pkt_burst_io_forward(struct fwd_stream *fs) */ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); +#ifndef RTE_LIBRTE_PMD_BOND if (unlikely(nb_rx == 0)) return; +#else + if (unlikely(nb_rx == 0 && (fs->forward_timeout == 0 || + fs->next_forward_time > rte_rdtsc()))) + return; + + if (fs->forward_timeout != 0) + fs->next_forward_time = rte_rdtsc() + fs->forward_timeout; +#endif #ifdef RTE_TEST_PMD_RECORD_BURST_STATS fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; diff --git a/app/test-pmd/macfwd-retry.c b/app/test-pmd/macfwd-retry.c index 83da26f..fd100c0 100644 --- a/app/test-pmd/macfwd-retry.c +++ b/app/test-pmd/macfwd-retry.c @@ -110,8 +110,17 @@ pkt_burst_mac_retry_forward(struct fwd_stream *fs) */ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); +#ifndef RTE_LIBRTE_PMD_BOND if (unlikely(nb_rx == 0)) return; +#else + if (unlikely(nb_rx == 0 && (fs->forward_timeout == 0 || + fs->next_forward_time > rte_rdtsc()))) + return; + + if (fs->forward_timeout != 0) + fs->next_forward_time = rte_rdtsc() + fs->forward_timeout; +#endif #ifdef RTE_TEST_PMD_RECORD_BURST_STATS fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; diff --git a/app/test-pmd/macfwd.c b/app/test-pmd/macfwd.c index 38bae23..2fa7d7d 100644 --- a/app/test-pmd/macfwd.c +++ b/app/test-pmd/macfwd.c @@ -100,8 +100,17 @@ pkt_burst_mac_forward(struct fwd_stream *fs) */ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); +#ifndef RTE_LIBRTE_PMD_BOND if (unlikely(nb_rx == 0)) return; +#else + if (unlikely(nb_rx == 0 && (fs->forward_timeout == 0 || + fs->next_forward_time > rte_rdtsc()))) + return; + + if (fs->forward_timeout != 0) + fs->next_forward_time = rte_rdtsc() + fs->forward_timeout; +#endif #ifdef RTE_TEST_PMD_RECORD_BURST_STATS fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; diff --git a/app/test-pmd/macswap.c b/app/test-pmd/macswap.c index 1786095..042670d 100644 --- a/app/test-pmd/macswap.c +++ b/app/test-pmd/macswap.c @@ -100,8 +100,17 @@ pkt_burst_mac_swap(struct fwd_stream *fs) */ nb_rx = rte_eth_rx_burst(fs->rx_port, fs->rx_queue, pkts_burst, nb_pkt_per_burst); +#ifndef RTE_LIBRTE_PMD_BOND if (unlikely(nb_rx == 0)) return; +#else + if (unlikely(nb_rx == 0 && (fs->forward_timeout == 0 || + fs->next_forward_time > rte_rdtsc()))) + return; + + if (fs->forward_timeout != 0) + fs->next_forward_time = rte_rdtsc() + fs->forward_timeout; +#endif #ifdef RTE_TEST_PMD_RECORD_BURST_STATS fs->rx_burst_stats.pkt_burst_spread[nb_rx]++; diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 5740804..68e2987 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -72,6 +72,9 @@ #include #include #include +#ifdef RTE_LIBRTE_PMD_BOND +#include +#endif #ifdef RTE_LIBRTE_PMD_XENVIRT #include #endif @@ -1022,9 +1025,11 @@ start_packet_forwarding(int with_tx_first) port_fwd_begin_t port_fwd_begin; port_fwd_end_t port_fwd_end; struct rte_port *port; + struct fwd_stream *fs; unsigned int i; portid_t pt_id; streamid_t sm_id; + uint8_t is_mode4; if (all_ports_started() == 0) { printf("Not all ports were started\n"); @@ -1050,7 +1055,6 @@ start_packet_forwarding(int with_tx_first) return; } } - test_done = 0; if(!no_flush_rx) flush_fwd_rx_queues(); @@ -1067,11 +1071,35 @@ start_packet_forwarding(int with_tx_first) map_port_queue_stats_mapping_registers(pt_id, port); } for (sm_id = 0; sm_id < cur_fwd_config.nb_fwd_streams; sm_id++) { - fwd_streams[sm_id]->rx_packets = 0; - fwd_streams[sm_id]->tx_packets = 0; - fwd_streams[sm_id]->fwd_dropped = 0; - fwd_streams[sm_id]->rx_bad_ip_csum = 0; - fwd_streams[sm_id]->rx_bad_l4_csum = 0; + fs = fwd_streams[sm_id]; + fs->rx_packets = 0; + fs->tx_packets = 0; + fs->fwd_dropped = 0; + fs->rx_bad_ip_csum = 0; + fs->rx_bad_l4_csum = 0; + +#ifdef RTE_LIBRTE_PMD_BOND + is_mode4 = ports[fs->rx_port].bond_mode == BONDING_MODE_8023AD || + ports[fs->tx_port].bond_mode == BONDING_MODE_8023AD; + + if (is_mode4) { + if (cur_fwd_config.fwd_eng == &rx_only_engine || + cur_fwd_config.fwd_eng == &tx_only_engine +#ifdef RTE_LIBRTE_IEEE1588 + || cur_fwd_config.fwd_eng == &ieee1588_fwd_engine, +#endif + ) { + printf("Selected forwarding engine '%s' is not supported in " + "mode 802.3ad of link bonding.\n", + cur_fwd_config.fwd_eng->fwd_mode_name); + + return; + } + fs->forward_timeout = 100 * rte_get_tsc_hz() / 1000; + fs->next_forward_time = 0; /* force forward */ + } else + fs->forward_timeout = 0; /* force forward is disabled */ +#endif #ifdef RTE_TEST_PMD_RECORD_BURST_STATS memset(&fwd_streams[sm_id]->rx_burst_stats, 0, @@ -1083,6 +1111,9 @@ start_packet_forwarding(int with_tx_first) fwd_streams[sm_id]->core_cycles = 0; #endif } + + test_done = 0; + if (with_tx_first) { port_fwd_begin = tx_only_engine.port_fwd_begin; if (port_fwd_begin != NULL) { @@ -1284,6 +1315,11 @@ start_port(portid_t pid) struct rte_port *port; struct ether_addr mac_addr; + if (pid >= nb_ports && pid != RTE_PORT_ALL) { + printf("Invalid port id %u\n", pid); + return -1; + } + if (test_done == 0) { printf("Please stop forwarding first\n"); return -1; diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 5a3423c..4830775 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -40,7 +40,7 @@ int main(int argc, char **argv); #endif -#define RTE_PORT_ALL (~(portid_t)0x0) +#define RTE_PORT_ALL ((portid_t)(~0x0)) #define RTE_TEST_RX_DESC_MAX 2048 #define RTE_TEST_TX_DESC_MAX 2048 @@ -121,6 +121,10 @@ struct fwd_stream { struct pkt_burst_stats rx_burst_stats; struct pkt_burst_stats tx_burst_stats; #endif +#ifdef RTE_LIBRTE_PMD_BOND + uint64_t forward_timeout; /** Timeout used to force RX/TX */ + uint64_t next_forward_time; /**< Next time when RX/TX should be issued. */ +#endif }; /** @@ -152,7 +156,10 @@ struct rte_port { uint8_t need_reconfig; /**< need reconfiguring port or not */ uint8_t need_reconfig_queues; /**< need reconfiguring queues or not */ uint8_t rss_flag; /**< enable rss or not */ - uint8_t dcb_flag; /**< enable dcb */ + uint8_t dcb_flag; /**< enable dcb */ +#ifdef RTE_LIBRTE_PMD_BOND + int8_t bond_mode; /**< Port bonding mode */ +#endif struct rte_eth_rxconf rx_conf; /**< rx configuration */ struct rte_eth_txconf tx_conf; /**< tx configuration */ }; -- 1.7.9.5