New upstream version 18.08
[deb_dpdk.git] / examples / ip_reassembly / main.c
index 350a973..b830f67 100644 (file)
@@ -164,7 +164,6 @@ static struct rte_eth_conf port_conf = {
                .mq_mode        = ETH_MQ_RX_RSS,
                .max_rx_pkt_len = JUMBO_FRAME_MAX_SIZE,
                .split_hdr_size = 0,
-               .ignore_offload_bitfield = 1,
                .offloads = (DEV_RX_OFFLOAD_CHECKSUM |
                             DEV_RX_OFFLOAD_JUMBO_FRAME |
                             DEV_RX_OFFLOAD_CRC_STRIP),
@@ -702,7 +701,7 @@ print_ethaddr(const char *name, const struct ether_addr *eth_addr)
 
 /* Check the link status of all ports in up to 9s, and print them finally */
 static void
-check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
+check_all_ports_link_status(uint32_t port_mask)
 {
 #define CHECK_INTERVAL 100 /* 100ms */
 #define MAX_CHECK_TIME 90 /* 9s (90 * 100ms) in total */
@@ -714,7 +713,7 @@ check_all_ports_link_status(uint16_t port_num, uint32_t port_mask)
        fflush(stdout);
        for (count = 0; count <= MAX_CHECK_TIME; count++) {
                all_ports_up = 1;
-               for (portid = 0; portid < port_num; portid++) {
+               RTE_ETH_FOREACH_DEV(portid) {
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
@@ -1008,7 +1007,7 @@ main(int argc, char **argv)
        if (ret < 0)
                rte_exit(EXIT_FAILURE, "Invalid IP reassembly parameters\n");
 
-       nb_ports = rte_eth_dev_count();
+       nb_ports = rte_eth_dev_count_avail();
        if (nb_ports == 0)
                rte_exit(EXIT_FAILURE, "No ports found!\n");
 
@@ -1023,7 +1022,7 @@ main(int argc, char **argv)
                rte_exit(EXIT_FAILURE, "Non-existent ports in portmask!\n");
 
        /* initialize all ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                struct rte_eth_rxconf rxq_conf;
                struct rte_eth_conf local_port_conf = port_conf;
 
@@ -1083,6 +1082,18 @@ main(int argc, char **argv)
                if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
                        local_port_conf.txmode.offloads |=
                                DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+               local_port_conf.rx_adv_conf.rss_conf.rss_hf &=
+                       dev_info.flow_type_rss_offloads;
+               if (local_port_conf.rx_adv_conf.rss_conf.rss_hf !=
+                               port_conf.rx_adv_conf.rss_conf.rss_hf) {
+                       printf("Port %u modified RSS hash function based on hardware support,"
+                               "requested:%#"PRIx64" configured:%#"PRIx64"\n",
+                               portid,
+                               port_conf.rx_adv_conf.rss_conf.rss_hf,
+                               local_port_conf.rx_adv_conf.rss_conf.rss_hf);
+               }
+
                ret = rte_eth_dev_configure(portid, 1, (uint16_t)n_tx_queue,
                                            &local_port_conf);
                if (ret < 0) {
@@ -1121,7 +1132,6 @@ main(int argc, char **argv)
                        fflush(stdout);
 
                        txconf = &dev_info.default_txconf;
-                       txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
                        txconf->offloads = local_port_conf.txmode.offloads;
 
                        ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd,
@@ -1141,7 +1151,7 @@ main(int argc, char **argv)
        printf("\n");
 
        /* start ports */
-       for (portid = 0; portid < nb_ports; portid++) {
+       RTE_ETH_FOREACH_DEV(portid) {
                if ((enabled_port_mask & (1 << portid)) == 0) {
                        continue;
                }
@@ -1157,7 +1167,7 @@ main(int argc, char **argv)
        if (init_routing_table() < 0)
                rte_exit(EXIT_FAILURE, "Cannot init routing table\n");
 
-       check_all_ports_link_status(nb_ports, enabled_port_mask);
+       check_all_ports_link_status(enabled_port_mask);
 
        signal(SIGUSR1, signal_handler);
        signal(SIGTERM, signal_handler);