app/pipeline: move from test directory
[dpdk.git] / examples / ip_fragmentation / main.c
index 8952ea4..e90a61e 100644 (file)
 #define        IPV4_MTU_DEFAULT        ETHER_MTU
 #define        IPV6_MTU_DEFAULT        ETHER_MTU
 
+/*
+ * The overhead from max frame size to MTU.
+ * We have to consider the max possible overhead.
+ */
+#define MTU_OVERHEAD   \
+       (ETHER_HDR_LEN + ETHER_CRC_LEN + 2 * sizeof(struct vlan_hdr))
+
 /*
  * Default payload in bytes for the IPv6 packet.
  */
@@ -140,10 +147,9 @@ static struct rte_eth_conf port_conf = {
        .rxmode = {
                .max_rx_pkt_len = JUMBO_FRAME_MAX_SIZE,
                .split_hdr_size = 0,
-               .ignore_offload_bitfield = 1,
                .offloads = (DEV_RX_OFFLOAD_CHECKSUM |
-                            DEV_RX_OFFLOAD_JUMBO_FRAME |
-                            DEV_RX_OFFLOAD_CRC_STRIP),
+                            DEV_RX_OFFLOAD_SCATTER |
+                            DEV_RX_OFFLOAD_JUMBO_FRAME),
        },
        .txmode = {
                .mq_mode = ETH_MQ_TX_NONE,
@@ -937,6 +943,16 @@ main(int argc, char **argv)
                                ret, portid);
                }
 
+               /* set the mtu to the maximum received packet size */
+               ret = rte_eth_dev_set_mtu(portid,
+                       local_port_conf.rxmode.max_rx_pkt_len - MTU_OVERHEAD);
+               if (ret < 0) {
+                       printf("\n");
+                       rte_exit(EXIT_FAILURE, "Set MTU failed: "
+                               "err=%d, port=%d\n",
+                       ret, portid);
+               }
+
                ret = rte_eth_dev_adjust_nb_rx_tx_desc(portid, &nb_rxd,
                                            &nb_txd);
                if (ret < 0) {
@@ -973,7 +989,6 @@ main(int argc, char **argv)
                        fflush(stdout);
 
                        txconf = &dev_info.default_txconf;
-                       txconf->txq_flags = ETH_TXQ_FLAGS_IGNORE;
                        txconf->offloads = local_port_conf.txmode.offloads;
                        ret = rte_eth_tx_queue_setup(portid, queueid, nb_txd,
                                                     socket, txconf);