* Multi-flow generation mode. * * We originate a bunch of flows (varying destination IP addresses), and * terminate receive traffic. Received traffic is simply discarded, but we * still do so in order to maintain traffic statistics. */
| 59 | * still do so in order to maintain traffic statistics. |
| 60 | */ |
| 61 | static bool |
| 62 | pkt_burst_flow_gen(struct fwd_stream *fs) |
| 63 | { |
| 64 | unsigned pkt_size = tx_pkt_length - 4; /* Adjust FCS */ |
| 65 | struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; |
| 66 | struct rte_mempool *mbp; |
| 67 | struct rte_mbuf *pkt = NULL; |
| 68 | struct rte_ether_hdr *eth_hdr; |
| 69 | struct rte_ipv4_hdr *ip_hdr; |
| 70 | struct rte_udp_hdr *udp_hdr; |
| 71 | uint16_t vlan_tci, vlan_tci_outer; |
| 72 | uint64_t ol_flags = 0; |
| 73 | uint16_t nb_rx; |
| 74 | uint16_t nb_tx; |
| 75 | uint16_t nb_dropped; |
| 76 | uint16_t nb_pkt; |
| 77 | uint16_t nb_clones = nb_pkt_flowgen_clones; |
| 78 | uint64_t tx_offloads; |
| 79 | int next_flow = RTE_PER_LCORE(_next_flow); |
| 80 | |
| 81 | /* Receive a burst of packets and discard them. */ |
| 82 | nb_rx = common_fwd_stream_receive(fs, pkts_burst, nb_pkt_per_burst); |
| 83 | |
| 84 | rte_pktmbuf_free_bulk(pkts_burst, nb_rx); |
| 85 | |
| 86 | mbp = current_fwd_lcore()->mbp; |
| 87 | vlan_tci = ports[fs->tx_port].tx_vlan_id; |
| 88 | vlan_tci_outer = ports[fs->tx_port].tx_vlan_id_outer; |
| 89 | |
| 90 | tx_offloads = ports[fs->tx_port].dev_conf.txmode.offloads; |
| 91 | if (tx_offloads & RTE_ETH_TX_OFFLOAD_VLAN_INSERT) |
| 92 | ol_flags |= RTE_MBUF_F_TX_VLAN; |
| 93 | if (tx_offloads & RTE_ETH_TX_OFFLOAD_QINQ_INSERT) |
| 94 | ol_flags |= RTE_MBUF_F_TX_QINQ; |
| 95 | if (tx_offloads & RTE_ETH_TX_OFFLOAD_MACSEC_INSERT) |
| 96 | ol_flags |= RTE_MBUF_F_TX_MACSEC; |
| 97 | |
| 98 | for (nb_pkt = 0; nb_pkt < nb_pkt_per_burst; nb_pkt++) { |
| 99 | if (!nb_pkt || !nb_clones) { |
| 100 | nb_clones = nb_pkt_flowgen_clones; |
| 101 | /* Logic limitation */ |
| 102 | if (nb_clones > nb_pkt_per_burst) |
| 103 | nb_clones = nb_pkt_per_burst; |
| 104 | |
| 105 | pkt = rte_mbuf_raw_alloc(mbp); |
| 106 | if (!pkt) |
| 107 | break; |
| 108 | |
| 109 | pkt->data_len = pkt_size; |
| 110 | pkt->next = NULL; |
| 111 | |
| 112 | /* Initialize Ethernet header. */ |
| 113 | eth_hdr = rte_pktmbuf_mtod(pkt, struct rte_ether_hdr *); |
| 114 | rte_ether_addr_copy(&cfg_ether_dst, ð_hdr->dst_addr); |
| 115 | rte_ether_addr_copy(&cfg_ether_src, ð_hdr->src_addr); |
| 116 | eth_hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4); |
| 117 | |
| 118 | /* Initialize IP header. */ |
nothing calls this directly
no test coverage detected