examples: fix RSS hash function configuration
[dpdk.git] / examples / qos_meter / main.c
index ca0e9e8..5cf4e9d 100644 (file)
@@ -332,6 +332,17 @@ main(int argc, char **argv)
        rte_eth_dev_info_get(port_rx, &dev_info);
        if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
                conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+       conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+       if (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",
+                       port_rx,
+                       port_conf.rx_adv_conf.rss_conf.rss_hf,
+                       conf.rx_adv_conf.rss_conf.rss_hf);
+       }
+
        ret = rte_eth_dev_configure(port_rx, 1, 1, &conf);
        if (ret < 0)
                rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_rx, ret);
@@ -361,6 +372,17 @@ main(int argc, char **argv)
        rte_eth_dev_info_get(port_tx, &dev_info);
        if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
                conf.txmode.offloads |= DEV_TX_OFFLOAD_MBUF_FAST_FREE;
+
+       conf.rx_adv_conf.rss_conf.rss_hf &= dev_info.flow_type_rss_offloads;
+       if (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",
+                       port_tx,
+                       port_conf.rx_adv_conf.rss_conf.rss_hf,
+                       conf.rx_adv_conf.rss_conf.rss_hf);
+       }
+
        ret = rte_eth_dev_configure(port_tx, 1, 1, &conf);
        if (ret < 0)
                rte_exit(EXIT_FAILURE, "Port %d configuration error (%d)\n", port_tx, ret);