From: Intel Date: Wed, 19 Dec 2012 23:00:00 +0000 (+0100) Subject: app/testpmd: various updates X-Git-Tag: spdx-start~11315 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=013af9b6b64f6e72aed00aead63c2842c7c4ff4f;p=dpdk.git app/testpmd: various updates Signed-off-by: Intel --- diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 809d2b5980..64d7855147 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -214,7 +214,7 @@ port_infos_display(portid_t port_id) return; } port = &ports[port_id]; - rte_eth_link_get(port_id, &link); + rte_eth_link_get_nowait(port_id, &link); printf("\n%s Infos for port %-2d %s\n", info_border, port_id, info_border); print_ethaddr("MAC address: ", &port->eth_addr); @@ -665,6 +665,9 @@ simple_fwd_config_setup(void) cur_fwd_config.nb_fwd_streams = (streamid_t) cur_fwd_config.nb_fwd_ports; + /* reinitialize forwarding streams */ + init_fwd_streams(); + /* * In the simple forwarding test, the number of forwarding cores * must be lower or equal to the number of forwarding ports. @@ -730,6 +733,10 @@ rss_fwd_config_setup(void) else cur_fwd_config.nb_fwd_lcores = (lcoreid_t)cur_fwd_config.nb_fwd_streams; + + /* reinitialize forwarding streams */ + init_fwd_streams(); + setup_fwd_config_of_each_lcore(&cur_fwd_config); rxp = 0; rxq = 0; for (lc_id = 0; lc_id < cur_fwd_config.nb_fwd_lcores; lc_id++) { @@ -931,7 +938,7 @@ fwd_config_display(void) pkt_fwd_config_display(&cur_fwd_config); } -void +int set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc) { unsigned int i; @@ -943,13 +950,15 @@ set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc) for (i = 0; i < nb_lc; i++) { lcore_cpuid = lcorelist[i]; if (! rte_lcore_is_enabled(lcore_cpuid)) { - printf("Logical core %u not enabled\n", lcore_cpuid); - return; + printf("lcore %u not enabled\n", lcore_cpuid); + return -1; } if (lcore_cpuid == rte_get_master_lcore()) { - printf("Master core %u cannot forward packets\n", + printf("lcore %u cannot be masked on for running " + "packet forwarding, which is the master lcore " + "and reserved for command line parsing only\n", lcore_cpuid); - return; + return -1; } if (record_now) fwd_lcores_cpuids[i] = lcore_cpuid; @@ -965,9 +974,11 @@ set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc) (unsigned int) nb_fwd_lcores, nb_lc); nb_fwd_lcores = (lcoreid_t) nb_lc; } + + return 0; } -void +int set_fwd_lcores_mask(uint64_t lcoremask) { unsigned int lcorelist[64]; @@ -976,7 +987,7 @@ set_fwd_lcores_mask(uint64_t lcoremask) if (lcoremask == 0) { printf("Invalid NULL mask of cores\n"); - return; + return -1; } nb_lc = 0; for (i = 0; i < 64; i++) { @@ -984,7 +995,7 @@ set_fwd_lcores_mask(uint64_t lcoremask) continue; lcorelist[nb_lc++] = i; } - set_fwd_lcores_list(lcorelist, nb_lc); + return set_fwd_lcores_list(lcorelist, nb_lc); } void @@ -1422,13 +1433,13 @@ fdir_get_infos(portid_t port_id) rte_eth_dev_fdir_get_infos(port_id, &fdir_infos); - printf("\n %s FDIR infos for port %-2d %s\n", + printf("\n %s FDIR infos for port %-2d %s\n", fdir_stats_border, port_id, fdir_stats_border); - printf(" collision: %-10"PRIu64" free: %-10"PRIu64"\n" - " maxhash: %-10"PRIu64" maxlen: %-10"PRIu64"\n" - " add : %-10"PRIu64" remove : %-10"PRIu64"\n" - " f_add: %-10"PRIu64" f_remove: %-10"PRIu64"\n", + printf(" collision: %-10"PRIu64" free: %"PRIu64"\n" + " maxhash: %-10"PRIu64" maxlen: %"PRIu64"\n" + " add: %-10"PRIu64" remove: %"PRIu64"\n" + " f_add: %-10"PRIu64" f_remove: %"PRIu64"\n", (uint64_t)(fdir_infos.collision), (uint64_t)(fdir_infos.free), (uint64_t)(fdir_infos.maxhash), (uint64_t)(fdir_infos.maxlen), fdir_infos.add, fdir_infos.remove, diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index b5bc5eb188..d1e1a4e273 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -132,8 +132,8 @@ get_ipv4_cksum(struct ipv4_hdr *ipv4_hdr) } -static inline -uint16_t get_ipv4_psd_sum (struct ipv4_hdr * ip_hdr) +static inline uint16_t +get_ipv4_psd_sum (struct ipv4_hdr * ip_hdr) { struct psd_header psd_hdr; psd_hdr.src_addr = ip_hdr->src_addr; @@ -145,11 +145,11 @@ uint16_t get_ipv4_psd_sum (struct ipv4_hdr * ip_hdr) return get_16b_sum((uint16_t*)&psd_hdr, sizeof(struct psd_header)); } -static inline -uint16_t get_ipv6_psd_sum (struct ipv6_hdr * ip_hdr) +static inline uint16_t +get_ipv6_psd_sum (struct ipv6_hdr * ip_hdr) { struct ipv6_psd_header psd_hdr; - rte_memcpy(psd_hdr.src_addr, ip_hdr->src_addr, sizeof(ip_hdr->src_addr) + rte_memcpy(&psd_hdr.src_addr, ip_hdr->src_addr, sizeof(ip_hdr->src_addr) + sizeof(ip_hdr->dst_addr)); psd_hdr.zero[0] = 0; @@ -224,6 +224,7 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) uint16_t pkt_ol_flags; uint16_t tx_ol_flags; uint16_t l4_proto; + uint16_t eth_type; uint8_t l2_len; uint8_t l3_len; @@ -266,15 +267,30 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) ol_flags = (uint16_t) (pkt_ol_flags & (~PKT_TX_L4_MASK)); eth_hdr = (struct ether_hdr *) mb->pkt.data; - if (rte_be_to_cpu_16(eth_hdr->ether_type) == ETHER_TYPE_VLAN) { + eth_type = rte_be_to_cpu_16(eth_hdr->ether_type); + if (eth_type == ETHER_TYPE_VLAN) { /* Only allow single VLAN label here */ l2_len += sizeof(struct vlan_hdr); + eth_type = rte_be_to_cpu_16(*(uint16_t *) + ((uintptr_t)ð_hdr->ether_type + + sizeof(struct vlan_hdr))); } /* Update the L3/L4 checksum error packet count */ rx_bad_ip_csum += (uint16_t) ((pkt_ol_flags & PKT_RX_IP_CKSUM_BAD) != 0); rx_bad_l4_csum += (uint16_t) ((pkt_ol_flags & PKT_RX_L4_CKSUM_BAD) != 0); + /* + * Try to figure out L3 packet type by SW. + */ + if ((pkt_ol_flags & (PKT_RX_IPV4_HDR | PKT_RX_IPV4_HDR_EXT | + PKT_RX_IPV6_HDR | PKT_RX_IPV6_HDR_EXT)) == 0) { + if (eth_type == ETHER_TYPE_IPv4) + pkt_ol_flags |= PKT_RX_IPV4_HDR; + else if (eth_type == ETHER_TYPE_IPv6) + pkt_ol_flags |= PKT_RX_IPV6_HDR; + } + /* * Simplify the protocol parsing * Assuming the incoming packets format as @@ -354,8 +370,8 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) } /* End of L4 Handling*/ } + else if (pkt_ol_flags & PKT_RX_IPV6_HDR) { - else { ipv6_hdr = (struct ipv6_hdr *) (rte_pktmbuf_mtod(mb, unsigned char *) + l2_len); l3_len = sizeof(struct ipv6_hdr) ; @@ -409,7 +425,11 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) } else { printf("Test flow control for 1G PMD \n"); } - /* End of L4 Handling*/ + /* End of L6 Handling*/ + } + else { + l3_len = 0; + printf("Unhandled packet type: %#hx\n", eth_type); } /* Combine the packet header write. VLAN is not consider here */ diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index df56e26d10..6325b39f0b 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -102,7 +102,9 @@ usage(char* progname) printf(" --nb-ports=N set the number of forwarding ports" " (1 <= N <= %d)\n", nb_ports); printf(" --coremask=COREMASK: hexadecimal bitmask of cores running " - "the packet forwarding test\n"); + "the packet forwarding test. The master lcore is reserved for " + "command line parsing only, and can not be masked on for running" + "the packet forwarding\n"); printf(" --portmask=PORTMASK: hexadecimal bitmask of ports used " "by the packet forwarding test\n"); printf(" --numa: enable NUMA-aware allocation of RX/TX rings and of " @@ -129,6 +131,7 @@ usage(char* progname) printf(" --crc-strip: enable CRC stripping by hardware\n"); printf(" --enable-rx-cksum: enable rx hardware checksum offload\n"); printf(" --disable-hw-vlan: disable hardware vlan\n"); + printf(" --enable-drop-en: enable per queue packet drop\n"); printf(" --disable-rss: disable rss\n"); printf(" --port-topology=N: set port topology (N: paired (default) or " "chained)\n"); @@ -212,8 +215,8 @@ parse_fwd_coremask(const char *coremask) cm = strtoull(coremask, &end, 16); if ((coremask[0] == '\0') || (end == NULL) || (*end != '\0')) rte_exit(EXIT_FAILURE, "Invalid fwd core mask\n"); - else - set_fwd_lcores_mask((uint64_t) cm); + else if (set_fwd_lcores_mask((uint64_t) cm) < 0) + rte_exit(EXIT_FAILURE, "coremask is not valid\n"); } /* @@ -322,6 +325,8 @@ launch_args_parse(int argc, char** argv) int n, opt; char **argvopt; int opt_idx; + enum { TX, RX }; + static struct option lgopts[] = { { "help", 0, 0, 0 }, { "interactive", 0, 0, 0 }, @@ -342,7 +347,9 @@ launch_args_parse(int argc, char** argv) { "pkt-filter-flexbytes-offset",1, 0, 0 }, { "pkt-filter-drop-queue", 1, 0, 0 }, { "crc-strip", 0, 0, 0 }, + { "enable-rx-cksum", 0, 0, 0 }, { "disable-hw-vlan", 0, 0, 0 }, + { "enable-drop-en", 0, 0, 0 }, { "disable-rss", 0, 0, 0 }, { "port-topology", 1, 0, 0 }, { "rss-ip", 0, 0, 0 }, @@ -562,8 +569,8 @@ launch_args_parse(int argc, char** argv) if (!strcmp(lgopts[opt_idx].name, "rss-ip")) rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6; if (!strcmp(lgopts[opt_idx].name, "rss-udp")) - rss_hf = ETH_RSS_IPV4 | ETH_RSS_IPV6 | - ETH_RSS_IPV4_UDP; + rss_hf = ETH_RSS_IPV4 | + ETH_RSS_IPV6 | ETH_RSS_IPV4_UDP; if (!strcmp(lgopts[opt_idx].name, "rxq")) { n = atoi(optarg); if (n >= 1 && n <= (int) MAX_QUEUE_ID) diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index f2df50bc05..d4226ddff7 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -628,40 +628,83 @@ static void fwd_port_stats_display(portid_t port_id, struct rte_eth_stats *stats) { struct rte_port *port; + uint8_t i; static const char *fwd_stats_border = "----------------------"; port = &ports[port_id]; printf("\n %s Forward statistics for port %-2d %s\n", - fwd_stats_border, port_id, fwd_stats_border); - printf(" RX-packets: %-14"PRIu64" RX-dropped: %-14"PRIu64"RX-total: " - "%-"PRIu64"\n", - stats->ipackets, stats->ierrors, - (uint64_t) (stats->ipackets + stats->ierrors)); + fwd_stats_border, port_id, fwd_stats_border); - if (cur_fwd_eng == &csum_fwd_engine) - printf(" Bad-ipcsum: %-14"PRIu64" Bad-l4csum: %-14"PRIu64" \n", - port->rx_bad_ip_csum, port->rx_bad_l4_csum); + if ((!port->rx_queue_stats_mapping_enabled) && (!port->tx_queue_stats_mapping_enabled)) { + printf(" RX-packets: %-14"PRIu64" RX-dropped: %-14"PRIu64"RX-total: " + "%-"PRIu64"\n", + stats->ipackets, stats->ierrors, + (uint64_t) (stats->ipackets + stats->ierrors)); - printf(" TX-packets: %-14"PRIu64" TX-dropped: %-14"PRIu64"TX-total: " - "%-"PRIu64"\n", - stats->opackets, port->tx_dropped, - (uint64_t) (stats->opackets + port->tx_dropped)); + if (cur_fwd_eng == &csum_fwd_engine) + printf(" Bad-ipcsum: %-14"PRIu64" Bad-l4csum: %-14"PRIu64" \n", + port->rx_bad_ip_csum, port->rx_bad_l4_csum); - if (stats->rx_nombuf > 0) - printf(" RX-nombufs: %-14"PRIu64"\n", stats->rx_nombuf); + printf(" TX-packets: %-14"PRIu64" TX-dropped: %-14"PRIu64"TX-total: " + "%-"PRIu64"\n", + stats->opackets, port->tx_dropped, + (uint64_t) (stats->opackets + port->tx_dropped)); + + if (stats->rx_nombuf > 0) + printf(" RX-nombufs: %-14"PRIu64"\n", stats->rx_nombuf); + + } + else { + printf(" RX-packets: %14"PRIu64" RX-dropped:%14"PRIu64" RX-total:" + "%14"PRIu64"\n", + stats->ipackets, stats->ierrors, + (uint64_t) (stats->ipackets + stats->ierrors)); + + if (cur_fwd_eng == &csum_fwd_engine) + printf(" Bad-ipcsum:%14"PRIu64" Bad-l4csum:%14"PRIu64"\n", + port->rx_bad_ip_csum, port->rx_bad_l4_csum); + + printf(" TX-packets: %14"PRIu64" TX-dropped:%14"PRIu64" TX-total:" + "%14"PRIu64"\n", + stats->opackets, port->tx_dropped, + (uint64_t) (stats->opackets + port->tx_dropped)); + + if (stats->rx_nombuf > 0) + printf(" RX-nombufs:%14"PRIu64"\n", stats->rx_nombuf); + } #ifdef RTE_TEST_PMD_RECORD_BURST_STATS if (port->rx_stream) - pkt_burst_stats_display("RX", &port->rx_stream->rx_burst_stats); + pkt_burst_stats_display("RX", + &port->rx_stream->rx_burst_stats); if (port->tx_stream) - pkt_burst_stats_display("TX", &port->tx_stream->tx_burst_stats); + pkt_burst_stats_display("TX", + &port->tx_stream->tx_burst_stats); #endif /* stats fdir */ if (fdir_conf.mode != RTE_FDIR_MODE_NONE) - printf(" Fdirmiss: %-14"PRIu64" Fdirmatch: %-14"PRIu64"\n", + printf(" Fdirmiss:%14"PRIu64" Fdirmatch:%14"PRIu64"\n", stats->fdirmiss, stats->fdirmatch); + if (port->rx_queue_stats_mapping_enabled) { + printf("\n"); + for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) { + printf(" Stats reg %2d RX-packets:%14"PRIu64 + " RX-errors:%14"PRIu64 + " RX-bytes:%14"PRIu64"\n", + i, stats->q_ipackets[i], stats->q_errors[i], stats->q_ibytes[i]); + } + printf("\n"); + } + if (port->tx_queue_stats_mapping_enabled) { + for (i = 0; i < RTE_ETHDEV_QUEUE_STAT_CNTRS; i++) { + printf(" Stats reg %2d TX-packets:%14"PRIu64 + " TX-bytes:%14"PRIu64"\n", + i, stats->q_opackets[i], stats->q_obytes[i]); + } + } + printf(" %s--------------------------------%s\n", fwd_stats_border, fwd_stats_border); } @@ -685,8 +728,8 @@ fwd_stream_stats_display(streamid_t stream_id) /* if checksum mode */ if (cur_fwd_eng == &csum_fwd_engine) { - printf(" RX- bad IP checksum: %-14u Rx- bad L4 checksum: %-14u\n", - fs->rx_bad_ip_csum, fs->rx_bad_l4_csum); + printf(" RX- bad IP checksum: %-14u Rx- bad L4 checksum: " + "%-14u\n", fs->rx_bad_ip_csum, fs->rx_bad_l4_csum); } #ifdef RTE_TEST_PMD_RECORD_BURST_STATS @@ -710,8 +753,7 @@ flush_all_rx_queues(void) for (rxq = 0; rxq < nb_rxq; rxq++) { do { nb_rx = rte_eth_rx_burst(rxp, rxq, - pkts_burst, - MAX_PKT_BURST); + pkts_burst, MAX_PKT_BURST); for (i = 0; i < nb_rx; i++) rte_pktmbuf_free(pkts_burst[i]); } while (nb_rx > 0); @@ -813,6 +855,10 @@ start_packet_forwarding(int with_tx_first) printf("Packet forwarding already started\n"); return; } + if((dcb_test) && (nb_fwd_lcores == 1)) { + printf("In DCB mode,the nb forwarding cores should be larger than 1.\n"); + return; + } test_done = 0; flush_all_rx_queues(); fwd_config_setup(); @@ -823,6 +869,8 @@ start_packet_forwarding(int with_tx_first) port = &ports[pt_id]; rte_eth_stats_get(pt_id, &port->stats); port->tx_dropped = 0; + + 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; @@ -921,15 +969,19 @@ stop_packet_forwarding(void) fwd_streams[sm_id]->fwd_dropped); ports[fwd_streams[sm_id]->tx_port].tx_dropped = tx_dropped; - rx_bad_ip_csum = ports[fwd_streams[sm_id]->rx_port].rx_bad_ip_csum; + rx_bad_ip_csum = + ports[fwd_streams[sm_id]->rx_port].rx_bad_ip_csum; rx_bad_ip_csum = (uint64_t) (rx_bad_ip_csum + fwd_streams[sm_id]->rx_bad_ip_csum); - ports[fwd_streams[sm_id]->rx_port].rx_bad_ip_csum = rx_bad_ip_csum; + ports[fwd_streams[sm_id]->rx_port].rx_bad_ip_csum = + rx_bad_ip_csum; - rx_bad_l4_csum = ports[fwd_streams[sm_id]->rx_port].rx_bad_l4_csum; + rx_bad_l4_csum = + ports[fwd_streams[sm_id]->rx_port].rx_bad_l4_csum; rx_bad_l4_csum = (uint64_t) (rx_bad_l4_csum + fwd_streams[sm_id]->rx_bad_l4_csum); - ports[fwd_streams[sm_id]->rx_port].rx_bad_l4_csum = rx_bad_l4_csum; + ports[fwd_streams[sm_id]->rx_port].rx_bad_l4_csum = + rx_bad_l4_csum; #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES fwd_cycles = (uint64_t) (fwd_cycles + @@ -1298,97 +1350,241 @@ check_all_ports_link_status(uint8_t port_num, uint32_t port_mask) } } -static void -init_ports(void) +static int +set_tx_queue_stats_mapping_registers(uint8_t port_id, struct rte_port *port) { - struct rte_eth_link link; - struct rte_eth_conf port_conf = { - .intr_conf = { - .lsc = 0, - }, - }; - struct rte_eth_rxconf rx_conf; - struct rte_eth_txconf tx_conf; - struct rte_port *port; - unsigned int sock_id; - portid_t pi; - queueid_t qi; + uint16_t i; int diag; + uint8_t mapping_found = 0; + + for (i = 0; i < nb_tx_queue_stats_mappings; i++) { + if ((tx_queue_stats_mappings[i].port_id == port_id) && + (tx_queue_stats_mappings[i].queue_id < nb_txq )) { + diag = rte_eth_dev_set_tx_queue_stats_mapping(port_id, + tx_queue_stats_mappings[i].queue_id, + tx_queue_stats_mappings[i].stats_counter_id); + if (diag != 0) + return diag; + mapping_found = 1; + } + } + if (mapping_found) + port->tx_queue_stats_mapping_enabled = 1; + return 0; +} - port_conf.rxmode = rx_mode; - port_conf.fdir_conf = fdir_conf; - - if (nb_rxq > 0) { /* configure RSS */ - port_conf.rx_adv_conf.rss_conf.rss_key = NULL; - /* use default hash key */ - port_conf.rx_adv_conf.rss_conf.rss_hf = rss_hf; - } else - port_conf.rx_adv_conf.rss_conf.rss_hf = 0; - rx_conf.rx_thresh = rx_thresh; - rx_conf.rx_free_thresh = rx_free_thresh; - tx_conf.tx_thresh = tx_thresh; - tx_conf.tx_rs_thresh = tx_rs_thresh; - tx_conf.tx_free_thresh = tx_free_thresh; +static int +set_rx_queue_stats_mapping_registers(uint8_t port_id, struct rte_port *port) +{ + uint16_t i; + int diag; + uint8_t mapping_found = 0; + + for (i = 0; i < nb_rx_queue_stats_mappings; i++) { + if ((rx_queue_stats_mappings[i].port_id == port_id) && + (rx_queue_stats_mappings[i].queue_id < nb_rxq )) { + diag = rte_eth_dev_set_rx_queue_stats_mapping(port_id, + rx_queue_stats_mappings[i].queue_id, + rx_queue_stats_mappings[i].stats_counter_id); + if (diag != 0) + return diag; + mapping_found = 1; + } + } + if (mapping_found) + port->rx_queue_stats_mapping_enabled = 1; + return 0; +} - for (pi = 0; pi < nb_ports; pi++) { - port = &ports[pi]; - memcpy(&port->dev_conf, &port_conf, sizeof(port_conf)); - sock_id = port->socket_id; - printf("Initializing port %d... ", pi); - fflush(stdout); - diag = rte_eth_dev_configure(pi, nb_rxq, nb_txq, &port_conf); - if (diag != 0) { - fatal_init_error("rte_eth_dev_configure", pi, diag); - /* NOT REACHED */ +static void +map_port_queue_stats_mapping_registers(uint8_t pi, struct rte_port *port) +{ + int diag = 0; + + diag = set_tx_queue_stats_mapping_registers(pi, port); + if (diag != 0) { + if (diag == -ENOTSUP) { + port->tx_queue_stats_mapping_enabled = 0; + printf("TX queue stats mapping not supported port id=%d\n", pi); } - rte_eth_macaddr_get(pi, &port->eth_addr); - for (qi = 0; qi < nb_txq; qi++) { - diag = rte_eth_tx_queue_setup(pi, qi, nb_txd, - sock_id, - &tx_conf); - if (diag != 0) { - fatal_init_error("rte_eth_tx_queue_setup", - pi, diag); - /* NOT REACHED */ - } + else + rte_exit(EXIT_FAILURE, + "set_tx_queue_stats_mapping_registers " + "failed for port id=%d diag=%d\n", + pi, diag); + } + + diag = set_rx_queue_stats_mapping_registers(pi, port); + if (diag != 0) { + if (diag == -ENOTSUP) { + port->rx_queue_stats_mapping_enabled = 0; + printf("RX queue stats mapping not supported port id=%d\n", pi); } - for (qi = 0; qi < nb_rxq; qi++) { - diag = rte_eth_rx_queue_setup(pi, qi, nb_rxd, sock_id, - &rx_conf, - mbuf_pool_find(sock_id)); - if (diag != 0) { - fatal_init_error("rte_eth_rx_queue_setup", - pi , diag); - /* NOT REACHED */ - } + else + rte_exit(EXIT_FAILURE, + "set_rx_queue_stats_mapping_registers " + "failed for port id=%d diag=%d\n", + pi, diag); + } +} + +void +init_port_config(void) +{ + portid_t pid; + struct rte_port *port; + + for (pid = 0; pid < nb_ports; pid++) { + port = &ports[pid]; + port->dev_conf.rxmode = rx_mode; + port->dev_conf.fdir_conf = fdir_conf; + if (nb_rxq > 0) { + port->dev_conf.rx_adv_conf.rss_conf.rss_key = NULL; + port->dev_conf.rx_adv_conf.rss_conf.rss_hf = rss_hf; + } else { + port->dev_conf.rx_adv_conf.rss_conf.rss_key = NULL; + port->dev_conf.rx_adv_conf.rss_conf.rss_hf = 0; } + port->rx_conf.rx_thresh = rx_thresh; + port->rx_conf.rx_free_thresh = rx_free_thresh; + port->rx_conf.rx_drop_en = rx_drop_en; + port->tx_conf.tx_thresh = tx_thresh; + port->tx_conf.tx_rs_thresh = tx_rs_thresh; + port->tx_conf.tx_free_thresh = tx_free_thresh; + port->tx_conf.txq_flags = txq_flags; + + rte_eth_macaddr_get(pid, &port->eth_addr); - /* Start device */ - diag = rte_eth_dev_start(pi); - if (diag != 0) { - fatal_init_error("rte_eth_dev_start", pi, diag); - /* NOT REACHED */ + map_port_queue_stats_mapping_registers(pid, port); + } +} + +const uint16_t vlan_tags[] = { + 0, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 19, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31 +}; + +static int +get_eth_dcb_conf(struct rte_eth_conf *eth_conf, struct dcb_config *dcb_conf) +{ + uint8_t i; + + /* + * Builds up the correct configuration for dcb+vt based on the vlan tags array + * given above, and the number of traffic classes available for use. + */ + if (dcb_conf->dcb_mode == DCB_VT_ENABLED) { + struct rte_eth_vmdq_dcb_conf vmdq_rx_conf; + struct rte_eth_vmdq_dcb_tx_conf vmdq_tx_conf; + + /* VMDQ+DCB RX and TX configrations */ + vmdq_rx_conf.enable_default_pool = 0; + vmdq_rx_conf.default_pool = 0; + vmdq_rx_conf.nb_queue_pools = + (dcb_conf->num_tcs == ETH_4_TCS ? ETH_32_POOLS : ETH_16_POOLS); + vmdq_tx_conf.nb_queue_pools = + (dcb_conf->num_tcs == ETH_4_TCS ? ETH_32_POOLS : ETH_16_POOLS); + + vmdq_rx_conf.nb_pool_maps = sizeof( vlan_tags )/sizeof( vlan_tags[ 0 ]); + for (i = 0; i < vmdq_rx_conf.nb_pool_maps; i++) { + vmdq_rx_conf.pool_map[i].vlan_id = vlan_tags[ i ]; + vmdq_rx_conf.pool_map[i].pools = 1 << (i % vmdq_rx_conf.nb_queue_pools); } - printf("done: "); - rte_eth_link_get(pi, &link); - if (link.link_status) { - printf(" Link Up - speed %u Mbps - %s\n", - (unsigned) link.link_speed, - (link.link_duplex == ETH_LINK_FULL_DUPLEX) ? - ("full-duplex") : ("half-duplex\n")); - } else { - printf(" Link Down\n"); + for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++) { + vmdq_rx_conf.dcb_queue[i] = i; + vmdq_tx_conf.dcb_queue[i] = i; } + + /*set DCB mode of RX and TX of multiple queues*/ + eth_conf->rxmode.mq_mode = ETH_VMDQ_DCB; + eth_conf->txmode.mq_mode = ETH_VMDQ_DCB_TX; + if (dcb_conf->pfc_en) + eth_conf->dcb_capability_en = ETH_DCB_PG_SUPPORT|ETH_DCB_PFC_SUPPORT; + else + eth_conf->dcb_capability_en = ETH_DCB_PG_SUPPORT; + + (void)(rte_memcpy(ð_conf->rx_adv_conf.vmdq_dcb_conf, &vmdq_rx_conf, + sizeof(struct rte_eth_vmdq_dcb_conf))); + (void)(rte_memcpy(ð_conf->tx_adv_conf.vmdq_dcb_tx_conf, &vmdq_tx_conf, + sizeof(struct rte_eth_vmdq_dcb_tx_conf))); + } + else { + struct rte_eth_dcb_rx_conf rx_conf; + struct rte_eth_dcb_tx_conf tx_conf; + + /* queue mapping configuration of DCB RX and TX */ + if (dcb_conf->num_tcs == ETH_4_TCS) + dcb_q_mapping = DCB_4_TCS_Q_MAPPING; + else + dcb_q_mapping = DCB_8_TCS_Q_MAPPING; + + rx_conf.nb_tcs = dcb_conf->num_tcs; + tx_conf.nb_tcs = dcb_conf->num_tcs; + + for (i = 0; i < ETH_DCB_NUM_USER_PRIORITIES; i++){ + rx_conf.dcb_queue[i] = i; + tx_conf.dcb_queue[i] = i; + } + eth_conf->rxmode.mq_mode = ETH_DCB_RX; + eth_conf->txmode.mq_mode = ETH_DCB_TX; + if (dcb_conf->pfc_en) + eth_conf->dcb_capability_en = ETH_DCB_PG_SUPPORT|ETH_DCB_PFC_SUPPORT; + else + eth_conf->dcb_capability_en = ETH_DCB_PG_SUPPORT; + + (void)(rte_memcpy(ð_conf->rx_adv_conf.dcb_rx_conf, &rx_conf, + sizeof(struct rte_eth_dcb_rx_conf))); + (void)(rte_memcpy(ð_conf->tx_adv_conf.dcb_tx_conf, &tx_conf, + sizeof(struct rte_eth_dcb_tx_conf))); + } - /* - * If enabled, put device in promiscuous mode. - * This allows the PMD test in IO forwarding mode to forward - * packets to itself through 2 cross-connected ports of the - * target machine. - */ - if (promiscuous_on) - rte_eth_promiscuous_enable(pi); + return 0; +} + +int +init_port_dcb_config(portid_t pid,struct dcb_config *dcb_conf) +{ + struct rte_eth_conf port_conf; + struct rte_port *rte_port; + int retval; + uint16_t nb_vlan; + uint16_t i; + + /* rxq and txq configuration in dcb mode */ + nb_rxq = 128; + nb_txq = 128; + rx_free_thresh = 64; + + memset(&port_conf,0,sizeof(struct rte_eth_conf)); + /* Enter DCB configuration status */ + dcb_config = 1; + + nb_vlan = sizeof( vlan_tags )/sizeof( vlan_tags[ 0 ]); + /*set configuration of DCB in vt mode and DCB in non-vt mode*/ + retval = get_eth_dcb_conf(&port_conf, dcb_conf); + if (retval < 0) + return retval; + + rte_port = &ports[pid]; + memcpy(&rte_port->dev_conf, &port_conf,sizeof(struct rte_eth_conf)); + + rte_port->rx_conf.rx_thresh = rx_thresh; + rte_port->rx_conf.rx_free_thresh = rx_free_thresh; + rte_port->tx_conf.tx_thresh = tx_thresh; + rte_port->tx_conf.tx_rs_thresh = tx_rs_thresh; + rte_port->tx_conf.tx_free_thresh = tx_free_thresh; + /* VLAN filter */ + rte_port->dev_conf.rxmode.hw_vlan_filter = 1; + for (i = 0; i < nb_vlan; i++){ + rx_vft_set(pid, vlan_tags[i], 1); } + + rte_eth_macaddr_get(pid, &rte_port->eth_addr); + map_port_queue_stats_mapping_registers(pid, rte_port); + + return 0; } #ifdef RTE_EXEC_ENV_BAREMETAL @@ -1399,6 +1595,7 @@ int main(int argc, char** argv) { int diag; + uint8_t port_id; diag = rte_eal_init(argc, argv); if (diag < 0) @@ -1412,7 +1609,8 @@ main(int argc, char** argv) nb_ports = (portid_t) rte_eth_dev_count(); if (nb_ports == 0) - rte_exit(EXIT_FAILURE, "No probed ethernet devices - check that " + rte_exit(EXIT_FAILURE, "No probed ethernet devices - " + "check that " "CONFIG_RTE_LIBRTE_IGB_PMD=y and that " "CONFIG_RTE_LIBRTE_EM_PMD=y and that " "CONFIG_RTE_LIBRTE_IXGBE_PMD=y in your " diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 0b4b42b9e3..dbaa8f5ca7 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -121,7 +121,7 @@ struct fwd_stream { /** * The data structure associated with each port. * tx_ol_flags is slightly different from ol_flags of rte_mbuf. - * Bit 0: Insert IP checksum + * Bit 0: Insert IP checksum * Bit 1: Insert UDP checksum * Bit 2: Insert TCP checksum * Bit 3: Insert SCTP checksum @@ -409,6 +409,8 @@ void fwd_config_display(void); void rxtx_config_display(void); void fwd_config_setup(void); void set_def_fwd_config(void); +int init_fwd_streams(void); + void port_reg_bit_display(portid_t port_id, uint32_t reg_off, uint8_t bit_pos); void port_reg_bit_set(portid_t port_id, uint32_t reg_off, uint8_t bit_pos, @@ -423,8 +425,8 @@ void port_reg_set(portid_t port_id, uint32_t reg_off, uint32_t value); void rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, uint16_t rxd_id); void tx_ring_desc_display(portid_t port_id, queueid_t txq_id, uint16_t txd_id); -void set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc); -void set_fwd_lcores_mask(uint64_t lcoremask); +int set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc); +int set_fwd_lcores_mask(uint64_t lcoremask); void set_fwd_lcores_number(uint16_t nb_lc); void set_fwd_ports_list(unsigned int *portlist, unsigned int nb_pt); diff --git a/app/test-pmd/txonly.c b/app/test-pmd/txonly.c index 63cc47a6cb..b943ca1bf3 100644 --- a/app/test-pmd/txonly.c +++ b/app/test-pmd/txonly.c @@ -94,8 +94,8 @@ tx_mbuf_alloc(struct rte_mempool *mp) struct rte_mbuf *m; m = __rte_mbuf_raw_alloc(mp); - __rte_mbuf_sanity_check(m, RTE_MBUF_PKT, 1); - return m; + __rte_mbuf_sanity_check_raw(m, RTE_MBUF_PKT, 0); + return (m); } static void