main processing loop */
| 187 | |
| 188 | /* main processing loop */ |
| 189 | static void |
| 190 | l2fwd_main_loop(void) |
| 191 | { |
| 192 | struct rte_mbuf *pkts_burst[MAX_PKT_BURST]; |
| 193 | struct rte_mbuf *m; |
| 194 | int sent; |
| 195 | unsigned lcore_id; |
| 196 | uint64_t prev_tsc, diff_tsc, cur_tsc; |
| 197 | unsigned i, j, portid, nb_rx; |
| 198 | struct lcore_queue_conf *qconf; |
| 199 | const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) |
| 200 | / US_PER_S * BURST_TX_DRAIN_US; |
| 201 | struct rte_eth_dev_tx_buffer *buffer; |
| 202 | |
| 203 | prev_tsc = 0; |
| 204 | |
| 205 | lcore_id = rte_lcore_id(); |
| 206 | qconf = &lcore_queue_conf[lcore_id]; |
| 207 | |
| 208 | if (qconf->n_rx_port == 0) { |
| 209 | RTE_LOG(INFO, L2FWD, "lcore %u has nothing to do\n", lcore_id); |
| 210 | return; |
| 211 | } |
| 212 | |
| 213 | RTE_LOG(INFO, L2FWD, "entering main loop on lcore %u\n", lcore_id); |
| 214 | |
| 215 | for (i = 0; i < qconf->n_rx_port; i++) { |
| 216 | |
| 217 | portid = qconf->rx_port_list[i]; |
| 218 | RTE_LOG(INFO, L2FWD, " -- lcoreid=%u portid=%u\n", lcore_id, |
| 219 | portid); |
| 220 | } |
| 221 | |
| 222 | uint64_t tsc_initial = rte_rdtsc(); |
| 223 | uint64_t tsc_lifetime = (rand()&0x07) * rte_get_tsc_hz(); |
| 224 | |
| 225 | while (!terminate_signal_received) { |
| 226 | /* Keepalive heartbeat. 8< */ |
| 227 | rte_keepalive_mark_alive(rte_global_keepalive_info); |
| 228 | |
| 229 | cur_tsc = rte_rdtsc(); |
| 230 | |
| 231 | /* |
| 232 | * Die randomly within 7 secs for demo purposes if |
| 233 | * keepalive enabled |
| 234 | */ |
| 235 | if (check_period > 0 && cur_tsc - tsc_initial > tsc_lifetime) |
| 236 | break; |
| 237 | /* >8 End of keepalive heartbeat. */ |
| 238 | |
| 239 | /* |
| 240 | * TX burst queue drain |
| 241 | */ |
| 242 | diff_tsc = cur_tsc - prev_tsc; |
| 243 | if (unlikely(diff_tsc > drain_tsc)) { |
| 244 | |
| 245 | for (i = 0; i < qconf->n_rx_port; i++) { |
| 246 |
no test coverage detected