crypto/scheduler: improve slave configuration
[dpdk.git] / examples / dpdk_qat / main.c
index 20e78bc..a96119c 100644 (file)
@@ -62,7 +62,6 @@
 #include <rte_debug.h>
 #include <rte_ether.h>
 #include <rte_ethdev.h>
-#include <rte_ring.h>
 #include <rte_mempool.h>
 #include <rte_mbuf.h>
 #include <rte_ip.h>
@@ -70,7 +69,6 @@
 
 #include "crypto.h"
 
-#define MBUF_SIZE (2048 + sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)
 #define NB_MBUF   (32 * 1024)
 
 #define MAX_PKT_BURST 32
@@ -326,8 +324,9 @@ main_loop(__attribute__((unused)) void *dummy)
                        continue;
                /* Send packet to either QAT encrypt, QAT decrypt or NIC TX */
                if (pkt_from_nic_rx) {
-                       struct ipv4_hdr *ip  = (struct ipv4_hdr *) (rte_pktmbuf_mtod(pkt, unsigned char *) +
-                                       sizeof(struct ether_hdr));
+                       struct ipv4_hdr *ip  = rte_pktmbuf_mtod_offset(pkt,
+                                                                      struct ipv4_hdr *,
+                                                                      sizeof(struct ether_hdr));
                        if (ip->src_addr & rte_cpu_to_be_32(ACTION_ENCRYPT)) {
                                if (CRYPTO_RESULT_FAIL == crypto_encrypt(pkt,
                                        (enum cipher_alg)((ip->src_addr >> 16) & 0xFF),
@@ -583,7 +582,7 @@ parse_args(int argc, char **argv)
                argv[optind-1] = prgname;
 
        ret = optind-1;
-       optind = 0; /* reset getopt lib */
+       optind = 1; /* reset getopt lib */
        return ret;
 }
 
@@ -598,7 +597,6 @@ print_ethaddr(const char *name, const struct ether_addr *eth_addr)
 static int
 init_mem(void)
 {
-       const unsigned flags = 0;
        int socketid;
        unsigned lcoreid;
        char s[64];
@@ -613,11 +611,8 @@ init_mem(void)
                if (pktmbuf_pool[socketid] == NULL) {
                        snprintf(s, sizeof(s), "mbuf_pool_%d", socketid);
                        pktmbuf_pool[socketid] =
-                               rte_mempool_create(s, NB_MBUF, MBUF_SIZE, 32,
-                                       sizeof(struct rte_pktmbuf_pool_private),
-                                       rte_pktmbuf_pool_init, NULL,
-                                       rte_pktmbuf_init, NULL,
-                                       socketid, flags);
+                               rte_pktmbuf_pool_create(s, NB_MBUF, 32, 0,
+                                       RTE_MBUF_DEFAULT_BUF_SIZE, socketid);
                        if (pktmbuf_pool[socketid] == NULL) {
                                printf("Cannot init mbuf pool on socket %d\n", socketid);
                                return -1;
@@ -665,8 +660,6 @@ main(int argc, char **argv)
                return -1;
 
        nb_ports = rte_eth_dev_count();
-       if (nb_ports > RTE_MAX_ETHPORTS)
-               nb_ports = RTE_MAX_ETHPORTS;
 
        if (check_port_config(nb_ports) < 0)
                rte_panic("check_port_config failed\n");