| 129 | } |
| 130 | |
| 131 | static void |
| 132 | pipeline_tx_first(struct test_pipeline *t, struct evt_options *opt) |
| 133 | { |
| 134 | #define TX_DEF_PACKET_LEN 64 |
| 135 | uint16_t eth_port_id = 0; |
| 136 | uint16_t pkt_sz, rc; |
| 137 | uint32_t i; |
| 138 | |
| 139 | pkt_sz = opt->tx_pkt_sz; |
| 140 | if (pkt_sz > opt->max_pkt_sz) |
| 141 | pkt_sz = opt->max_pkt_sz; |
| 142 | if (!pkt_sz) |
| 143 | pkt_sz = TX_DEF_PACKET_LEN; |
| 144 | |
| 145 | RTE_ETH_FOREACH_DEV(eth_port_id) { |
| 146 | struct rte_ether_addr src_mac; |
| 147 | struct rte_ether_addr dst_mac; |
| 148 | struct rte_ether_hdr eth_hdr; |
| 149 | |
| 150 | /* Send to the same dest.mac as port mac */ |
| 151 | rte_eth_macaddr_get(eth_port_id, &dst_mac); |
| 152 | rte_eth_random_addr((uint8_t *)&src_mac); |
| 153 | |
| 154 | rte_ether_addr_copy(&dst_mac, ð_hdr.dst_addr); |
| 155 | rte_ether_addr_copy(&src_mac, ð_hdr.src_addr); |
| 156 | eth_hdr.ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4); |
| 157 | |
| 158 | for (i = 0; i < opt->tx_first; i++) { |
| 159 | struct rte_udp_hdr *pkt_udp_hdr; |
| 160 | struct rte_ipv4_hdr ip_hdr; |
| 161 | struct rte_udp_hdr udp_hdr; |
| 162 | struct rte_mbuf *mbuf; |
| 163 | |
| 164 | mbuf = rte_pktmbuf_alloc( |
| 165 | opt->per_port_pool ? t->pool[i] : t->pool[0]); |
| 166 | if (mbuf == NULL) |
| 167 | continue; |
| 168 | |
| 169 | setup_pkt_udp_ip_headers( |
| 170 | &ip_hdr, &udp_hdr, |
| 171 | pkt_sz - sizeof(struct rte_ether_hdr) - |
| 172 | sizeof(struct rte_ipv4_hdr) - |
| 173 | sizeof(struct rte_udp_hdr), |
| 174 | eth_port_id, i); |
| 175 | mbuf->port = eth_port_id; |
| 176 | mbuf->data_len = pkt_sz; |
| 177 | mbuf->pkt_len = pkt_sz; |
| 178 | |
| 179 | /* Copy Ethernet header */ |
| 180 | rte_memcpy(rte_pktmbuf_mtod_offset(mbuf, char *, 0), |
| 181 | ð_hdr, sizeof(struct rte_ether_hdr)); |
| 182 | |
| 183 | /* Copy Ipv4 header */ |
| 184 | rte_memcpy(rte_pktmbuf_mtod_offset( |
| 185 | mbuf, char *, |
| 186 | sizeof(struct rte_ether_hdr)), |
| 187 | &ip_hdr, sizeof(struct rte_ipv4_hdr)); |
| 188 |
no test coverage detected