ethdev: remove jumbo offload flag
[dpdk.git] / examples / l3fwd-acl / main.c
index 0c44df7..410ec94 100644 (file)
@@ -20,7 +20,6 @@
 #include <rte_memcpy.h>
 #include <rte_eal.h>
 #include <rte_launch.h>
-#include <rte_atomic.h>
 #include <rte_cycles.h>
 #include <rte_prefetch.h>
 #include <rte_lcore.h>
@@ -39,6 +38,9 @@
 #include <rte_string_fns.h>
 #include <rte_acl.h>
 
+#include <cmdline_parse.h>
+#include <cmdline_parse_etheraddr.h>
+
 #if RTE_LOG_DP_LEVEL >= RTE_LOG_DEBUG
 #define L3FWDACL_DEBUG
 #endif
@@ -81,9 +83,6 @@
 static uint16_t nb_rxd = RTE_TEST_RX_DESC_DEFAULT;
 static uint16_t nb_txd = RTE_TEST_TX_DESC_DEFAULT;
 
-/* ethernet addresses of ports */
-static struct rte_ether_addr ports_eth_addr[RTE_MAX_ETHPORTS];
-
 /* mask of enabled ports */
 static uint32_t enabled_port_mask;
 static int promiscuous_on; /**< Ports set in promiscuous mode off by default. */
@@ -125,7 +124,6 @@ static uint16_t nb_lcore_params = sizeof(lcore_params_array_default) /
 static struct rte_eth_conf port_conf = {
        .rxmode = {
                .mq_mode        = ETH_MQ_RX_RSS,
-               .max_rx_pkt_len = RTE_ETHER_MAX_LEN,
                .split_hdr_size = 0,
                .offloads = DEV_RX_OFFLOAD_CHECKSUM,
        },
@@ -141,8 +139,47 @@ static struct rte_eth_conf port_conf = {
        },
 };
 
+static uint32_t max_pkt_len;
+
 static struct rte_mempool *pktmbuf_pool[NB_SOCKETS];
 
+/* ethernet addresses of ports */
+static struct rte_ether_hdr port_l2hdr[RTE_MAX_ETHPORTS];
+
+static const struct {
+       const char *name;
+       enum rte_acl_classify_alg alg;
+} acl_alg[] = {
+       {
+               .name = "scalar",
+               .alg = RTE_ACL_CLASSIFY_SCALAR,
+       },
+       {
+               .name = "sse",
+               .alg = RTE_ACL_CLASSIFY_SSE,
+       },
+       {
+               .name = "avx2",
+               .alg = RTE_ACL_CLASSIFY_AVX2,
+       },
+       {
+               .name = "neon",
+               .alg = RTE_ACL_CLASSIFY_NEON,
+       },
+       {
+               .name = "altivec",
+               .alg = RTE_ACL_CLASSIFY_ALTIVEC,
+       },
+       {
+               .name = "avx512x16",
+               .alg = RTE_ACL_CLASSIFY_AVX512X16,
+       },
+       {
+               .name = "avx512x32",
+               .alg = RTE_ACL_CLASSIFY_AVX512X32,
+       },
+};
+
 /***********************start of ACL part******************************/
 #ifdef DO_RFC_1812_CHECKS
 static inline int
@@ -158,12 +195,24 @@ send_single_packet(struct rte_mbuf *m, uint16_t port);
 #define ACL_LEAD_CHAR          ('@')
 #define ROUTE_LEAD_CHAR                ('R')
 #define COMMENT_LEAD_CHAR      ('#')
-#define OPTION_CONFIG          "config"
-#define OPTION_NONUMA          "no-numa"
-#define OPTION_ENBJMO          "enable-jumbo"
-#define OPTION_RULE_IPV4       "rule_ipv4"
-#define OPTION_RULE_IPV6       "rule_ipv6"
-#define OPTION_SCALAR          "scalar"
+
+enum {
+#define OPT_CONFIG      "config"
+       OPT_CONFIG_NUM = 256,
+#define OPT_NONUMA      "no-numa"
+       OPT_NONUMA_NUM,
+#define OPT_MAX_PKT_LEN "max-pkt-len"
+       OPT_MAX_PKT_LEN_NUM,
+#define OPT_RULE_IPV4   "rule_ipv4"
+       OPT_RULE_IPV4_NUM,
+#define OPT_RULE_IPV6  "rule_ipv6"
+       OPT_RULE_IPV6_NUM,
+#define OPT_ALG         "alg"
+       OPT_ALG_NUM,
+#define OPT_ETH_DEST    "eth-dest"
+       OPT_ETH_DEST_NUM,
+};
+
 #define ACL_DENY_SIGNATURE     0xf0000000
 #define RTE_LOGTYPE_L3FWDACL   RTE_LOGTYPE_USER3
 #define acl_log(format, ...)   RTE_LOG(ERR, L3FWDACL, format, ##__VA_ARGS__)
@@ -437,7 +486,7 @@ static struct {
 static struct{
        const char *rule_ipv4_name;
        const char *rule_ipv6_name;
-       int scalar;
+       enum rte_acl_classify_alg alg;
 } parm_config;
 
 const char cb_port_delim[] = ":";
@@ -1090,13 +1139,58 @@ add_rules(const char *rule_path,
        return 0;
 }
 
+static int
+usage_acl_alg(char *buf, size_t sz)
+{
+       uint32_t i, n, rc, tn;
+
+       n = 0;
+       tn = 0;
+       for (i = 0; i < RTE_DIM(acl_alg); i++) {
+               rc = snprintf(buf + n, sz - n,
+                       i == RTE_DIM(acl_alg) - 1 ? "%s" : "%s|",
+                       acl_alg[i].name);
+               tn += rc;
+               if (rc < sz - n)
+                       n += rc;
+       }
+
+       return tn;
+}
+
+static const char *
+str_acl_alg(enum rte_acl_classify_alg alg)
+{
+       uint32_t i;
+
+       for (i = 0; i != RTE_DIM(acl_alg); i++) {
+               if (alg == acl_alg[i].alg)
+                       return acl_alg[i].name;
+       }
+
+       return "default";
+}
+
+static enum rte_acl_classify_alg
+parse_acl_alg(const char *alg)
+{
+       uint32_t i;
+
+       for (i = 0; i != RTE_DIM(acl_alg); i++) {
+               if (strcmp(alg, acl_alg[i].name) == 0)
+                       return acl_alg[i].alg;
+       }
+
+       return RTE_ACL_CLASSIFY_DEFAULT;
+}
+
 static void
 dump_acl_config(void)
 {
        printf("ACL option are:\n");
-       printf(OPTION_RULE_IPV4": %s\n", parm_config.rule_ipv4_name);
-       printf(OPTION_RULE_IPV6": %s\n", parm_config.rule_ipv6_name);
-       printf(OPTION_SCALAR": %d\n", parm_config.scalar);
+       printf(OPT_RULE_IPV4": %s\n", parm_config.rule_ipv4_name);
+       printf(OPT_RULE_IPV6": %s\n", parm_config.rule_ipv6_name);
+       printf(OPT_ALG": %s\n", str_acl_alg(parm_config.alg));
 }
 
 static int
@@ -1137,8 +1231,8 @@ setup_acl(struct rte_acl_rule *route_base,
        if ((context = rte_acl_create(&acl_param)) == NULL)
                rte_exit(EXIT_FAILURE, "Failed to create ACL context\n");
 
-       if (parm_config.scalar && rte_acl_set_ctx_classify(context,
-                       RTE_ACL_CLASSIFY_SCALAR) != 0)
+       if (parm_config.alg != RTE_ACL_CLASSIFY_DEFAULT &&
+                       rte_acl_set_ctx_classify(context, parm_config.alg) != 0)
                rte_exit(EXIT_FAILURE,
                        "Failed to setup classify method for  ACL context\n");
 
@@ -1275,9 +1369,15 @@ send_single_packet(struct rte_mbuf *m, uint16_t port)
 {
        uint32_t lcore_id;
        struct lcore_conf *qconf;
+       struct rte_ether_hdr *eh;
 
        lcore_id = rte_lcore_id();
 
+       /* update src and dst mac*/
+       eh = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
+       memcpy(eh, &port_l2hdr[port],
+                       sizeof(eh->dst_addr) + sizeof(eh->src_addr));
+
        qconf = &lcore_conf[lcore_id];
        rte_eth_tx_buffer(port, qconf->tx_queue_id[port],
                        qconf->tx_buffer[port], m);
@@ -1326,7 +1426,7 @@ is_valid_ipv4_pkt(struct rte_ipv4_hdr *pkt, uint32_t link_len)
 
 /* main processing loop */
 static int
-main_loop(__attribute__((unused)) void *dummy)
+main_loop(__rte_unused void *dummy)
 {
        struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
        unsigned lcore_id;
@@ -1516,29 +1616,27 @@ init_lcore_rx_queues(void)
 static void
 print_usage(const char *prgname)
 {
+       char alg[PATH_MAX];
+
+       usage_acl_alg(alg, sizeof(alg));
        printf("%s [EAL options] -- -p PORTMASK -P"
-               "--"OPTION_RULE_IPV4"=FILE"
-               "--"OPTION_RULE_IPV6"=FILE"
-               "  [--"OPTION_CONFIG" (port,queue,lcore)[,(port,queue,lcore]]"
-               "  [--"OPTION_ENBJMO" [--max-pkt-len PKTLEN]]\n"
+               "  --"OPT_RULE_IPV4"=FILE"
+               "  --"OPT_RULE_IPV6"=FILE"
+               "  [--"OPT_CONFIG" (port,queue,lcore)[,(port,queue,lcore]]"
+               "  [--"OPT_MAX_PKT_LEN" PKTLEN]\n"
                "  -p PORTMASK: hexadecimal bitmask of ports to configure\n"
-               "  -P : enable promiscuous mode\n"
-               "  --"OPTION_CONFIG": (port,queue,lcore): "
-               "rx queues configuration\n"
-               "  --"OPTION_NONUMA": optional, disable numa awareness\n"
-               "  --"OPTION_ENBJMO": enable jumbo frame"
-               " which max packet len is PKTLEN in decimal (64-9600)\n"
-               "  --"OPTION_RULE_IPV4"=FILE: specify the ipv4 rules entries "
-               "file. "
+               "  -P: enable promiscuous mode\n"
+               "  --"OPT_CONFIG" (port,queue,lcore): rx queues configuration\n"
+               "  --"OPT_NONUMA": optional, disable numa awareness\n"
+               "  --"OPT_MAX_PKT_LEN" PKTLEN: maximum packet length in decimal (64-9600)\n"
+               "  --"OPT_RULE_IPV4"=FILE: specify the ipv4 rules entries file. "
                "Each rule occupy one line. "
                "2 kinds of rules are supported. "
                "One is ACL entry at while line leads with character '%c', "
-               "another is route entry at while line leads with "
-               "character '%c'.\n"
-               "  --"OPTION_RULE_IPV6"=FILE: specify the ipv6 rules "
-               "entries file.\n"
-               "  --"OPTION_SCALAR": Use scalar function to do lookup\n",
-               prgname, ACL_LEAD_CHAR, ROUTE_LEAD_CHAR);
+               "another is route entry at while line leads with character '%c'.\n"
+               "  --"OPT_RULE_IPV6"=FILE: specify the ipv6 rules entries file.\n"
+               "  --"OPT_ALG": ACL classify method to use, one of: %s\n",
+               prgname, ACL_LEAD_CHAR, ROUTE_LEAD_CHAR, alg);
 }
 
 static int
@@ -1567,10 +1665,7 @@ parse_portmask(const char *portmask)
        /* parse hexadecimal string */
        pm = strtoul(portmask, &end, 16);
        if ((portmask[0] == '\0') || (end == NULL) || (*end != '\0'))
-               return -1;
-
-       if (pm == 0)
-               return -1;
+               return 0;
 
        return pm;
 }
@@ -1630,6 +1725,27 @@ parse_config(const char *q_arg)
        return 0;
 }
 
+static const char *
+parse_eth_dest(const char *optarg)
+{
+       unsigned long portid;
+       char *port_end;
+
+       errno = 0;
+       portid = strtoul(optarg, &port_end, 0);
+       if (errno != 0 || port_end == optarg || *port_end++ != ',')
+               return "Invalid format";
+       else if (portid >= RTE_MAX_ETHPORTS)
+               return "port value exceeds RTE_MAX_ETHPORTS("
+                       RTE_STR(RTE_MAX_ETHPORTS) ")";
+
+       if (cmdline_parse_etheraddr(NULL, port_end,
+                       &port_l2hdr[portid].dst_addr,
+                       sizeof(port_l2hdr[portid].dst_addr)) < 0)
+               return "Invalid ethernet address";
+       return NULL;
+}
+
 /* Parse the argument given in the command line of the application */
 static int
 parse_args(int argc, char **argv)
@@ -1639,13 +1755,14 @@ parse_args(int argc, char **argv)
        int option_index;
        char *prgname = argv[0];
        static struct option lgopts[] = {
-               {OPTION_CONFIG, 1, 0, 0},
-               {OPTION_NONUMA, 0, 0, 0},
-               {OPTION_ENBJMO, 0, 0, 0},
-               {OPTION_RULE_IPV4, 1, 0, 0},
-               {OPTION_RULE_IPV6, 1, 0, 0},
-               {OPTION_SCALAR, 0, 0, 0},
-               {NULL, 0, 0, 0}
+               {OPT_CONFIG,      1, NULL, OPT_CONFIG_NUM      },
+               {OPT_NONUMA,      0, NULL, OPT_NONUMA_NUM      },
+               {OPT_MAX_PKT_LEN, 1, NULL, OPT_MAX_PKT_LEN_NUM },
+               {OPT_RULE_IPV4,   1, NULL, OPT_RULE_IPV4_NUM   },
+               {OPT_RULE_IPV6,   1, NULL, OPT_RULE_IPV6_NUM   },
+               {OPT_ALG,         1, NULL, OPT_ALG_NUM         },
+               {OPT_ETH_DEST,    1, NULL, OPT_ETH_DEST_NUM    },
+               {NULL,            0, 0,    0                   }
        };
 
        argvopt = argv;
@@ -1663,86 +1780,62 @@ parse_args(int argc, char **argv)
                                return -1;
                        }
                        break;
+
                case 'P':
                        printf("Promiscuous mode selected\n");
                        promiscuous_on = 1;
                        break;
 
                /* long options */
-               case 0:
-                       if (!strncmp(lgopts[option_index].name,
-                                       OPTION_CONFIG,
-                                       sizeof(OPTION_CONFIG))) {
-                               ret = parse_config(optarg);
-                               if (ret) {
-                                       printf("invalid config\n");
-                                       print_usage(prgname);
-                                       return -1;
-                               }
-                       }
-
-                       if (!strncmp(lgopts[option_index].name,
-                                       OPTION_NONUMA,
-                                       sizeof(OPTION_NONUMA))) {
-                               printf("numa is disabled\n");
-                               numa_on = 0;
-                       }
-
-                       if (!strncmp(lgopts[option_index].name,
-                                       OPTION_ENBJMO, sizeof(OPTION_ENBJMO))) {
-                               struct option lenopts = {
-                                       "max-pkt-len",
-                                       required_argument,
-                                       0,
-                                       0
-                               };
-
-                               printf("jumbo frame is enabled\n");
-                               port_conf.rxmode.offloads |=
-                                               DEV_RX_OFFLOAD_JUMBO_FRAME;
-                               port_conf.txmode.offloads |=
-                                               DEV_TX_OFFLOAD_MULTI_SEGS;
-
-                               /*
-                                * if no max-pkt-len set, then use the
-                                * default value RTE_ETHER_MAX_LEN
-                                */
-                               if (0 == getopt_long(argc, argvopt, "",
-                                               &lenopts, &option_index)) {
-                                       ret = parse_max_pkt_len(optarg);
-                                       if ((ret < 64) ||
-                                               (ret > MAX_JUMBO_PKT_LEN)) {
-                                               printf("invalid packet "
-                                                       "length\n");
-                                               print_usage(prgname);
-                                               return -1;
-                                       }
-                                       port_conf.rxmode.max_rx_pkt_len = ret;
-                               }
-                               printf("set jumbo frame max packet length "
-                                       "to %u\n",
-                                       (unsigned int)
-                                       port_conf.rxmode.max_rx_pkt_len);
+               case OPT_CONFIG_NUM:
+                       ret = parse_config(optarg);
+                       if (ret) {
+                               printf("invalid config\n");
+                               print_usage(prgname);
+                               return -1;
                        }
+                       break;
 
-                       if (!strncmp(lgopts[option_index].name,
-                                       OPTION_RULE_IPV4,
-                                       sizeof(OPTION_RULE_IPV4)))
-                               parm_config.rule_ipv4_name = optarg;
+               case OPT_NONUMA_NUM:
+                       printf("numa is disabled\n");
+                       numa_on = 0;
+                       break;
 
-                       if (!strncmp(lgopts[option_index].name,
-                                       OPTION_RULE_IPV6,
-                                       sizeof(OPTION_RULE_IPV6))) {
-                               parm_config.rule_ipv6_name = optarg;
-                       }
+               case OPT_MAX_PKT_LEN_NUM:
+                       printf("Custom frame size is configured\n");
+                       max_pkt_len = parse_max_pkt_len(optarg);
+                       break;
 
-                       if (!strncmp(lgopts[option_index].name,
-                                       OPTION_SCALAR, sizeof(OPTION_SCALAR)))
-                               parm_config.scalar = 1;
+               case OPT_RULE_IPV4_NUM:
+                       parm_config.rule_ipv4_name = optarg;
+                       break;
 
+               case OPT_RULE_IPV6_NUM:
+                       parm_config.rule_ipv6_name = optarg;
+                       break;
 
+               case OPT_ALG_NUM:
+                       parm_config.alg = parse_acl_alg(optarg);
+                       if (parm_config.alg ==
+                                       RTE_ACL_CLASSIFY_DEFAULT) {
+                               printf("unknown %s value:\"%s\"\n",
+                                       OPT_ALG, optarg);
+                               print_usage(prgname);
+                               return -1;
+                       }
                        break;
 
+               case OPT_ETH_DEST_NUM:
+               {
+                       const char *serr = parse_eth_dest(optarg);
+                       if (serr != NULL) {
+                               printf("invalid %s value:\"%s\": %s\n",
+                                       OPT_ETH_DEST, optarg, serr);
+                               print_usage(prgname);
+                               return -1;
+                       }
+                       break;
+               }
                default:
                        print_usage(prgname);
                        return -1;
@@ -1814,6 +1907,8 @@ check_all_ports_link_status(uint32_t port_mask)
        uint16_t portid;
        uint8_t count, all_ports_up, print_flag = 0;
        struct rte_eth_link link;
+       int ret;
+       char link_status_text[RTE_ETH_LINK_MAX_STR_LEN];
 
        printf("\nChecking link status");
        fflush(stdout);
@@ -1823,17 +1918,20 @@ check_all_ports_link_status(uint32_t port_mask)
                        if ((port_mask & (1 << portid)) == 0)
                                continue;
                        memset(&link, 0, sizeof(link));
-                       rte_eth_link_get_nowait(portid, &link);
+                       ret = rte_eth_link_get_nowait(portid, &link);
+                       if (ret < 0) {
+                               all_ports_up = 0;
+                               if (print_flag == 1)
+                                       printf("Port %u link get failed: %s\n",
+                                               portid, rte_strerror(-ret));
+                               continue;
+                       }
                        /* print link status if flag set */
                        if (print_flag == 1) {
-                               if (link.link_status)
-                                       printf(
-                                       "Port%d Link Up. Speed %u Mbps %s\n",
-                                               portid, link.link_speed,
-                               (link.link_duplex == ETH_LINK_FULL_DUPLEX) ?
-                                       ("full-duplex") : ("half-duplex\n"));
-                               else
-                                       printf("Port %d Link Down\n", portid);
+                               rte_eth_link_to_str(link_status_text,
+                                       sizeof(link_status_text), &link);
+                               printf("Port %d %s\n", portid,
+                                      link_status_text);
                                continue;
                        }
                        /* clear all_ports_up flag if any link down */
@@ -1860,6 +1958,56 @@ check_all_ports_link_status(uint32_t port_mask)
        }
 }
 
+/*
+ * build-up default vaues for dest MACs.
+ */
+static void
+set_default_dest_mac(void)
+{
+       uint32_t i;
+
+       for (i = 0; i != RTE_DIM(port_l2hdr); i++) {
+               port_l2hdr[i].dst_addr.addr_bytes[0] =
+                               RTE_ETHER_LOCAL_ADMIN_ADDR;
+               port_l2hdr[i].dst_addr.addr_bytes[5] = i;
+       }
+}
+
+static uint32_t
+eth_dev_get_overhead_len(uint32_t max_rx_pktlen, uint16_t max_mtu)
+{
+       uint32_t overhead_len;
+
+       if (max_mtu != UINT16_MAX && max_rx_pktlen > max_mtu)
+               overhead_len = max_rx_pktlen - max_mtu;
+       else
+               overhead_len = RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
+
+       return overhead_len;
+}
+
+static int
+config_port_max_pkt_len(struct rte_eth_conf *conf,
+               struct rte_eth_dev_info *dev_info)
+{
+       uint32_t overhead_len;
+
+       if (max_pkt_len == 0)
+               return 0;
+
+       if (max_pkt_len < RTE_ETHER_MIN_LEN || max_pkt_len > MAX_JUMBO_PKT_LEN)
+               return -1;
+
+       overhead_len = eth_dev_get_overhead_len(dev_info->max_rx_pktlen,
+                       dev_info->max_mtu);
+       conf->rxmode.mtu = max_pkt_len - overhead_len;
+
+       if (conf->rxmode.mtu > RTE_ETHER_MTU)
+               conf->txmode.offloads |= DEV_TX_OFFLOAD_MULTI_SEGS;
+
+       return 0;
+}
+
 int
 main(int argc, char **argv)
 {
@@ -1881,6 +2029,8 @@ main(int argc, char **argv)
        argc -= ret;
        argv += ret;
 
+       set_default_dest_mac();
+
        /* parse application arguments (after the EAL ones) */
        ret = parse_args(argc, argv);
        if (ret < 0)
@@ -1924,7 +2074,19 @@ main(int argc, char **argv)
                        n_tx_queue = MAX_TX_QUEUE_PER_PORT;
                printf("Creating queues: nb_rxq=%d nb_txq=%u... ",
                        nb_rx_queue, (unsigned)n_tx_queue);
-               rte_eth_dev_info_get(portid, &dev_info);
+
+               ret = rte_eth_dev_info_get(portid, &dev_info);
+               if (ret != 0)
+                       rte_exit(EXIT_FAILURE,
+                               "Error during getting device (port %u) info: %s\n",
+                               portid, strerror(-ret));
+
+               ret = config_port_max_pkt_len(&local_port_conf, &dev_info);
+               if (ret != 0)
+                       rte_exit(EXIT_FAILURE,
+                               "Invalid max packet length: %u (port %u)\n",
+                               max_pkt_len, portid);
+
                if (dev_info.tx_offload_capa & DEV_TX_OFFLOAD_MBUF_FAST_FREE)
                        local_port_conf.txmode.offloads |=
                                DEV_TX_OFFLOAD_MBUF_FAST_FREE;
@@ -1954,8 +2116,14 @@ main(int argc, char **argv)
                                "rte_eth_dev_adjust_nb_rx_tx_desc: err=%d, port=%d\n",
                                ret, portid);
 
-               rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
-               print_ethaddr(" Address:", &ports_eth_addr[portid]);
+               ret = rte_eth_macaddr_get(portid, &port_l2hdr[portid].src_addr);
+               if (ret < 0)
+                       rte_exit(EXIT_FAILURE,
+                               "rte_eth_macaddr_get: err=%d, port=%d\n",
+                               ret, portid);
+
+               print_ethaddr("Dst MAC:", &port_l2hdr[portid].dst_addr);
+               print_ethaddr(", Src MAC:", &port_l2hdr[portid].src_addr);
                printf(", ");
 
                /* init memory */
@@ -1994,7 +2162,12 @@ main(int argc, char **argv)
                        printf("txq=%u,%d,%d ", lcore_id, queueid, socketid);
                        fflush(stdout);
 
-                       rte_eth_dev_info_get(portid, &dev_info);
+                       ret = rte_eth_dev_info_get(portid, &dev_info);
+                       if (ret != 0)
+                               rte_exit(EXIT_FAILURE,
+                                       "Error during getting device (port %u) info: %s\n",
+                                       portid, strerror(-ret));
+
                        txconf = &dev_info.default_txconf;
                        txconf->offloads = local_port_conf.txmode.offloads;
                        ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd,
@@ -2036,7 +2209,12 @@ main(int argc, char **argv)
                        printf("rxq=%d,%d,%d ", portid, queueid, socketid);
                        fflush(stdout);
 
-                       rte_eth_dev_info_get(portid, &dev_info);
+                       ret = rte_eth_dev_info_get(portid, &dev_info);
+                       if (ret != 0)
+                               rte_exit(EXIT_FAILURE,
+                                       "Error during getting device (port %u) info: %s\n",
+                                       portid, strerror(-ret));
+
                        rxq_conf = dev_info.default_rxconf;
                        rxq_conf.offloads = port_conf.rxmode.offloads;
                        ret = rte_eth_rx_queue_setup(portid, queueid, nb_rxd,
@@ -2069,18 +2247,26 @@ main(int argc, char **argv)
                 * to itself through 2 cross-connected  ports of the
                 * target machine.
                 */
-               if (promiscuous_on)
-                       rte_eth_promiscuous_enable(portid);
+               if (promiscuous_on) {
+                       ret = rte_eth_promiscuous_enable(portid);
+                       if (ret != 0)
+                               rte_exit(EXIT_FAILURE,
+                                       "rte_eth_promiscuous_enable: err=%s, port=%u\n",
+                                       rte_strerror(-ret), portid);
+               }
        }
 
        check_all_ports_link_status(enabled_port_mask);
 
        /* launch per-lcore init on every lcore */
-       rte_eal_mp_remote_launch(main_loop, NULL, CALL_MASTER);
-       RTE_LCORE_FOREACH_SLAVE(lcore_id) {
+       rte_eal_mp_remote_launch(main_loop, NULL, CALL_MAIN);
+       RTE_LCORE_FOREACH_WORKER(lcore_id) {
                if (rte_eal_wait_lcore(lcore_id) < 0)
                        return -1;
        }
 
+       /* clean up the EAL */
+       rte_eal_cleanup();
+
        return 0;
 }