eal: add and use unaligned integer types
[dpdk.git] / app / test-pmd / txonly.c
index 8135264..9e66552 100644 (file)
@@ -51,7 +51,6 @@
 #include <rte_memcpy.h>
 #include <rte_memzone.h>
 #include <rte_launch.h>
-#include <rte_tailq.h>
 #include <rte_eal.h>
 #include <rte_per_lcore.h>
 #include <rte_lcore.h>
@@ -111,13 +110,13 @@ copy_buf_to_pkt_segs(void* buf, unsigned len, struct rte_mbuf *pkt,
                seg = seg->next;
        }
        copy_len = seg->data_len - offset;
-       seg_buf = ((char *) seg->data + offset);
+       seg_buf = (rte_pktmbuf_mtod(seg, char *) + offset);
        while (len > copy_len) {
                rte_memcpy(seg_buf, buf, (size_t) copy_len);
                len -= copy_len;
                buf = ((char*) buf + copy_len);
                seg = seg->next;
-               seg_buf = seg->data;
+               seg_buf = rte_pktmbuf_mtod(seg, char *);
        }
        rte_memcpy(seg_buf, buf, (size_t) len);
 }
@@ -126,7 +125,8 @@ static inline void
 copy_buf_to_pkt(void* buf, unsigned len, struct rte_mbuf *pkt, unsigned offset)
 {
        if (offset + len <= pkt->data_len) {
-               rte_memcpy(((char *) pkt->data + offset), buf, (size_t) len);
+               rte_memcpy((rte_pktmbuf_mtod(pkt, char *) + offset),
+                       buf, (size_t) len);
                return;
        }
        copy_buf_to_pkt_segs(buf, len, pkt, offset);
@@ -167,7 +167,7 @@ setup_pkt_udp_ip_headers(struct ipv4_hdr *ip_hdr,
        /*
         * Compute IP header checksum.
         */
-       ptr16 = (uint16_t*) ip_hdr;
+       ptr16 = (unaligned_uint16_t*) ip_hdr;
        ip_cksum = 0;
        ip_cksum += ptr16[0]; ip_cksum += ptr16[1];
        ip_cksum += ptr16[2]; ip_cksum += ptr16[3];
@@ -195,6 +195,7 @@ static void
 pkt_burst_transmit(struct fwd_stream *fs)
 {
        struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
+       struct rte_port *txp;
        struct rte_mbuf *pkt;
        struct rte_mbuf *pkt_seg;
        struct rte_mempool *mbp;
@@ -202,7 +203,7 @@ pkt_burst_transmit(struct fwd_stream *fs)
        uint16_t nb_tx;
        uint16_t nb_pkt;
        uint16_t vlan_tci;
-       uint16_t ol_flags;
+       uint64_t ol_flags = 0;
        uint8_t  i;
 #ifdef RTE_TEST_PMD_RECORD_CORE_CYCLES
        uint64_t start_tsc;
@@ -215,8 +216,10 @@ pkt_burst_transmit(struct fwd_stream *fs)
 #endif
 
        mbp = current_fwd_lcore()->mbp;
-       vlan_tci = ports[fs->tx_port].tx_vlan_id;
-       ol_flags = ports[fs->tx_port].tx_ol_flags;
+       txp = &ports[fs->tx_port];
+       vlan_tci = txp->tx_vlan_id;
+       if (txp->tx_ol_flags & TESTPMD_TX_OFFLOAD_INSERT_VLAN)
+               ol_flags = PKT_TX_VLAN_PKT;
        for (nb_pkt = 0; nb_pkt < nb_pkt_per_burst; nb_pkt++) {
                pkt = tx_mbuf_alloc(mbp);
                if (pkt == NULL) {