devargs: fix crash on failure
[dpdk.git] / examples / dpdk_qat / main.c
index 053be91..dc68989 100644 (file)
@@ -70,7 +70,6 @@
 
 #include "crypto.h"
 
-#define MBUF_DATA_SIZE (2048 + RTE_PKTMBUF_HEADROOM)
 #define NB_MBUF   (32 * 1024)
 
 #define MAX_PKT_BURST 32
@@ -326,8 +325,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),
@@ -613,7 +613,7 @@ init_mem(void)
                        snprintf(s, sizeof(s), "mbuf_pool_%d", socketid);
                        pktmbuf_pool[socketid] =
                                rte_pktmbuf_pool_create(s, NB_MBUF, 32, 0,
-                                       MBUF_DATA_SIZE, socketid);
+                                       RTE_MBUF_DEFAULT_BUF_SIZE, socketid);
                        if (pktmbuf_pool[socketid] == NULL) {
                                printf("Cannot init mbuf pool on socket %d\n", socketid);
                                return -1;