net/axgbe: support scattered Rx
[dpdk.git] / app / test-pmd / txonly.c
index a37aa5a..8a1989f 100644 (file)
@@ -45,13 +45,10 @@ uint16_t tx_udp_src_port = 9;
 uint16_t tx_udp_dst_port = 9;
 
 /* use RFC5735 / RFC2544 reserved network test addresses */
-uint32_t tx_ip_src_addr = (192U << 24) | (18 << 16) | (0 << 8) | 1;
-uint32_t tx_ip_dst_addr = (192U << 24) | (18 << 16) | (0 << 8) | 2;
+uint32_t tx_ip_src_addr = (198U << 24) | (18 << 16) | (0 << 8) | 1;
+uint32_t tx_ip_dst_addr = (198U << 24) | (18 << 16) | (0 << 8) | 2;
 
 #define IP_DEFTTL  64   /* from RFC 1340. */
-#define IP_VERSION 0x40
-#define IP_HDRLEN  0x05 /* default IP header length == five 32-bits words. */
-#define IP_VHL_DEF (IP_VERSION | IP_HDRLEN)
 
 static struct rte_ipv4_hdr pkt_ip_hdr; /**< IP header of transmitted packets. */
 RTE_DEFINE_PER_LCORE(uint8_t, _ip_var); /**< IP address variation */
@@ -116,7 +113,7 @@ setup_pkt_udp_ip_headers(struct rte_ipv4_hdr *ip_hdr,
         * Initialize IP header.
         */
        pkt_len = (uint16_t) (pkt_len + sizeof(struct rte_ipv4_hdr));
-       ip_hdr->version_ihl   = IP_VHL_DEF;
+       ip_hdr->version_ihl   = RTE_IPV4_VHL_DEF;
        ip_hdr->type_of_service   = 0;
        ip_hdr->fragment_offset = 0;
        ip_hdr->time_to_live   = IP_DEFTTL;
@@ -156,13 +153,12 @@ pkt_burst_prepare(struct rte_mbuf *pkt, struct rte_mempool *mbp,
                const uint16_t vlan_tci_outer, const uint64_t ol_flags)
 {
        struct rte_mbuf *pkt_segs[RTE_MAX_SEGS_PER_PKT];
-       uint8_t  ip_var = RTE_PER_LCORE(_ip_var);
        struct rte_mbuf *pkt_seg;
        uint32_t nb_segs, pkt_len;
        uint8_t i;
 
        if (unlikely(tx_pkt_split == TX_PKT_SPLIT_RND))
-               nb_segs = random() % tx_pkt_nb_segs + 1;
+               nb_segs = rte_rand() % tx_pkt_nb_segs + 1;
        else
                nb_segs = tx_pkt_nb_segs;
 
@@ -173,7 +169,8 @@ pkt_burst_prepare(struct rte_mbuf *pkt, struct rte_mempool *mbp,
 
        rte_pktmbuf_reset_headroom(pkt);
        pkt->data_len = tx_pkt_seg_lengths[0];
-       pkt->ol_flags = ol_flags;
+       pkt->ol_flags &= EXT_ATTACHED_MBUF;
+       pkt->ol_flags |= ol_flags;
        pkt->vlan_tci = vlan_tci;
        pkt->vlan_tci_outer = vlan_tci_outer;
        pkt->l2_len = sizeof(struct rte_ether_hdr);
@@ -195,6 +192,7 @@ pkt_burst_prepare(struct rte_mbuf *pkt, struct rte_mempool *mbp,
        copy_buf_to_pkt(&pkt_ip_hdr, sizeof(pkt_ip_hdr), pkt,
                        sizeof(struct rte_ether_hdr));
        if (txonly_multi_flow) {
+               uint8_t  ip_var = RTE_PER_LCORE(_ip_var);
                struct rte_ipv4_hdr *ip_hdr;
                uint32_t addr;
 
@@ -210,6 +208,7 @@ pkt_burst_prepare(struct rte_mbuf *pkt, struct rte_mempool *mbp,
                 */
                addr = (tx_ip_dst_addr | (ip_var++ << 8)) + rte_lcore_id();
                ip_hdr->src_addr = rte_cpu_to_be_32(addr);
+               RTE_PER_LCORE(_ip_var) = ip_var;
        }
        copy_buf_to_pkt(&pkt_udp_hdr, sizeof(pkt_udp_hdr), pkt,
                        sizeof(struct rte_ether_hdr) +
@@ -268,7 +267,7 @@ pkt_burst_transmit(struct fwd_stream *fs)
         */
        rte_ether_addr_copy(&peer_eth_addrs[fs->peer_addr], &eth_hdr.d_addr);
        rte_ether_addr_copy(&ports[fs->tx_port].eth_addr, &eth_hdr.s_addr);
-       eth_hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPv4);
+       eth_hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
 
        if (rte_mempool_get_bulk(mbp, (void **)pkts_burst,
                                nb_pkt_per_burst) == 0) {
@@ -317,7 +316,7 @@ pkt_burst_transmit(struct fwd_stream *fs)
        fs->tx_packets += nb_tx;
 
        if (txonly_multi_flow)
-               RTE_PER_LCORE(_ip_var) += nb_tx;
+               RTE_PER_LCORE(_ip_var) -= nb_pkt - nb_tx;
 
 #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
        fs->tx_burst_stats.pkt_burst_spread[nb_tx]++;