MCPcopy Create free account
hub / github.com/F-Stack/f-stack / flush_fwd_rx_queues

Function flush_fwd_rx_queues

dpdk/app/test-pmd/testpmd.c:2214–2266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2212}
2213
2214static void
2215flush_fwd_rx_queues(void)
2216{
2217 struct rte_mbuf *pkts_burst[MAX_PKT_BURST];
2218 portid_t rxp;
2219 portid_t port_id;
2220 queueid_t rxq;
2221 uint16_t nb_rx;
2222 uint8_t j;
2223 uint64_t prev_tsc = 0, diff_tsc, cur_tsc, timer_tsc = 0;
2224 uint64_t timer_period;
2225
2226 if (num_procs > 1) {
2227 printf("multi-process not support for flushing fwd Rx queues, skip the below lines and return.\n");
2228 return;
2229 }
2230
2231 /* convert to number of cycles */
2232 timer_period = rte_get_timer_hz(); /* 1 second timeout */
2233
2234 for (j = 0; j < 2; j++) {
2235 for (rxp = 0; rxp < cur_fwd_config.nb_fwd_ports; rxp++) {
2236 for (rxq = 0; rxq < nb_rxq; rxq++) {
2237 port_id = fwd_ports_ids[rxp];
2238
2239 /* Polling stopped queues is prohibited. */
2240 if (ports[port_id].rxq[rxq].state ==
2241 RTE_ETH_QUEUE_STATE_STOPPED)
2242 continue;
2243
2244 /**
2245 * testpmd can stuck in the below do while loop
2246 * if rte_eth_rx_burst() always returns nonzero
2247 * packets. So timer is added to exit this loop
2248 * after 1sec timer expiry.
2249 */
2250 prev_tsc = rte_rdtsc();
2251 do {
2252 nb_rx = rte_eth_rx_burst(port_id, rxq,
2253 pkts_burst, MAX_PKT_BURST);
2254 rte_pktmbuf_free_bulk(pkts_burst, nb_rx);
2255
2256 cur_tsc = rte_rdtsc();
2257 diff_tsc = cur_tsc - prev_tsc;
2258 timer_tsc += diff_tsc;
2259 } while ((nb_rx > 0) &&
2260 (timer_tsc < timer_period));
2261 timer_tsc = 0;
2262 }
2263 }
2264 rte_delay_ms(10); /* wait 10 milli-seconds before retrying */
2265 }
2266}
2267
2268static void
2269run_pkt_fwd_on_lcore(struct fwd_lcore *fc, packet_fwd_t pkt_fwd)

Callers 1

start_packet_forwardingFunction · 0.85

Calls 5

rte_eth_rx_burstFunction · 0.85
rte_pktmbuf_free_bulkFunction · 0.85
rte_delay_msFunction · 0.85
printfFunction · 0.50
rte_rdtscFunction · 0.50

Tested by

no test coverage detected