examples: check status of getting link info
[dpdk.git] / examples / ip_pipeline / link.c
index 2ccfea4..16bcffe 100644 (file)
@@ -48,7 +48,6 @@ static struct rte_eth_conf port_conf_default = {
                .mq_mode = ETH_MQ_RX_NONE,
                .max_rx_pkt_len = 9000, /* Jumbo frame max packet len */
                .split_hdr_size = 0, /* Header split buffer size */
-               .offloads = DEV_RX_OFFLOAD_CRC_STRIP,
        },
        .rx_adv_conf = {
                .rss_conf = {
@@ -130,7 +129,8 @@ link_create(const char *name, struct link_params *params)
                if (!rte_eth_dev_is_valid_port(port_id))
                        return NULL;
 
-       rte_eth_dev_info_get(port_id, &port_info);
+       if (rte_eth_dev_info_get(port_id, &port_info) != 0)
+               return NULL;
 
        mempool = mempool_find(params->rx.mempool_name);
        if (mempool == NULL)
@@ -158,12 +158,9 @@ link_create(const char *name, struct link_params *params)
        memcpy(&port_conf, &port_conf_default, sizeof(port_conf));
        if (rss) {
                port_conf.rxmode.mq_mode = ETH_MQ_RX_RSS;
-               if (port_info.flow_type_rss_offloads & ETH_RSS_IPV4)
-                       port_conf.rx_adv_conf.rss_conf.rss_hf |=
-                               ETH_RSS_IPV4;
-               if (port_info.flow_type_rss_offloads & ETH_RSS_IPV6)
-                       port_conf.rx_adv_conf.rss_conf.rss_hf |=
-                               ETH_RSS_IPV6;
+               port_conf.rx_adv_conf.rss_conf.rss_hf =
+                       (ETH_RSS_IP | ETH_RSS_TCP | ETH_RSS_UDP) &
+                       port_info.flow_type_rss_offloads;
        }
 
        cpu_id = (uint32_t) rte_eth_dev_socket_id(port_id);
@@ -179,8 +176,11 @@ link_create(const char *name, struct link_params *params)
        if (status < 0)
                return NULL;
 
-       if (params->promiscuous)
-               rte_eth_promiscuous_enable(port_id);
+       if (params->promiscuous) {
+               status = rte_eth_promiscuous_enable(port_id);
+               if (status != 0)
+                       return NULL;
+       }
 
        /* Port RX */
        for (i = 0; i < params->rx.n_queues; i++) {
@@ -264,7 +264,8 @@ link_is_up(const char *name)
                return 0;
 
        /* Resource */
-       rte_eth_link_get(link->port_id, &link_params);
+       if (rte_eth_link_get(link->port_id, &link_params) < 0)
+               return 0;
 
        return (link_params.link_status == ETH_LINK_DOWN) ? 0 : 1;
 }