app/testpmd: move header generation outside txonly loop
authorPavan Nikhilesh <pbhagavatula@marvell.com>
Tue, 2 Apr 2019 09:53:25 +0000 (09:53 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Fri, 5 Apr 2019 17:28:22 +0000 (19:28 +0200)
Testpmd txonly copies the src/dst mac address of the port being
processed to ethernet header structure on the stack for every packet.
Move it outside the loop and reuse it.

Signed-off-by: Pavan Nikhilesh <pbhagavatula@marvell.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
app/test-pmd/txonly.c

index def52a0..0d411db 100644 (file)
@@ -190,6 +190,14 @@ pkt_burst_transmit(struct fwd_stream *fs)
                ol_flags |= PKT_TX_QINQ_PKT;
        if (tx_offloads & DEV_TX_OFFLOAD_MACSEC_INSERT)
                ol_flags |= PKT_TX_MACSEC;
+
+       /*
+        * Initialize Ethernet header.
+        */
+       ether_addr_copy(&peer_eth_addrs[fs->peer_addr], &eth_hdr.d_addr);
+       ether_addr_copy(&ports[fs->tx_port].eth_addr, &eth_hdr.s_addr);
+       eth_hdr.ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
+
        for (nb_pkt = 0; nb_pkt < nb_pkt_per_burst; nb_pkt++) {
                pkt = rte_mbuf_raw_alloc(mbp);
                if (pkt == NULL) {
@@ -226,13 +234,6 @@ pkt_burst_transmit(struct fwd_stream *fs)
                }
                pkt_seg->next = NULL; /* Last segment of packet. */
 
-               /*
-                * Initialize Ethernet header.
-                */
-               ether_addr_copy(&peer_eth_addrs[fs->peer_addr],&eth_hdr.d_addr);
-               ether_addr_copy(&ports[fs->tx_port].eth_addr, &eth_hdr.s_addr);
-               eth_hdr.ether_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4);
-
                /*
                 * Copy headers in first packet segment(s).
                 */