spinlock: reimplement with atomic one-way barrier
[dpdk.git] / examples / distributor / main.c
index 62831a0..03a05e3 100644 (file)
@@ -80,7 +80,6 @@ static const struct rte_eth_conf port_conf_default = {
        .rxmode = {
                .mq_mode = ETH_MQ_RX_RSS,
                .max_rx_pkt_len = ETHER_MAX_LEN,
-               .ignore_offload_bitfield = 1,
        },
        .txmode = {
                .mq_mode = ETH_MQ_TX_NONE,
@@ -116,7 +115,7 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
        struct rte_eth_dev_info dev_info;
        struct rte_eth_txconf txconf;
 
-       if (port >= rte_eth_dev_count())
+       if (!rte_eth_dev_is_valid_port(port))
                return -1;
 
        rte_eth_dev_info_get(port, &dev_info);
@@ -124,6 +123,17 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
                port_conf.txmode.offloads |=
                        DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+       port_conf.rx_adv_conf.rss_conf.rss_hf &=
+               dev_info.flow_type_rss_offloads;
+       if (port_conf.rx_adv_conf.rss_conf.rss_hf !=
+                       port_conf_default.rx_adv_conf.rss_conf.rss_hf) {
+               printf("Port %u modified RSS hash function based on hardware support,"
+                       "requested:%#"PRIx64" configured:%#"PRIx64"\n",
+                       port,
+                       port_conf_default.rx_adv_conf.rss_conf.rss_hf,
+                       port_conf.rx_adv_conf.rss_conf.rss_hf);
+       }
+
        retval = rte_eth_dev_configure(port, rxRings, txRings, &port_conf);
        if (retval != 0)
                return retval;
@@ -141,7 +151,6 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
        }
 
        txconf = dev_info.default_txconf;
-       txconf.txq_flags = ETH_TXQ_FLAGS_IGNORE;
        txconf.offloads = port_conf.txmode.offloads;
        for (q = 0; q < txRings; q++) {
                retval = rte_eth_tx_queue_setup(port, q, nb_txd,
@@ -193,7 +202,7 @@ struct lcore_params {
 static int
 lcore_rx(struct lcore_params *p)
 {
-       const uint16_t nb_ports = rte_eth_dev_count();
+       const uint16_t nb_ports = rte_eth_dev_count_avail();
        const int socket_id = rte_socket_id();
        uint16_t port;
        struct rte_mbuf *bufs[BURST_SIZE*2];
@@ -542,7 +551,7 @@ lcore_worker(struct lcore_params *p)
         * for single port, xor_val will be zero so we won't modify the output
         * port, otherwise we send traffic from 0 to 1, 2 to 3, and vice versa
         */
-       const unsigned xor_val = (rte_eth_dev_count() > 1);
+       const unsigned xor_val = (rte_eth_dev_count_avail() > 1);
        struct rte_mbuf *buf[8] __rte_cache_aligned;
 
        for (i = 0; i < 8; i++)
@@ -678,7 +687,7 @@ main(int argc, char *argv[])
                                "1 lcore for packet TX\n"
                                "and at least 1 lcore for worker threads\n");
 
-       nb_ports = rte_eth_dev_count();
+       nb_ports = rte_eth_dev_count_avail();
        if (nb_ports == 0)
                rte_exit(EXIT_FAILURE, "Error: no ethernet ports detected\n");
        if (nb_ports != 1 && (nb_ports & 1))