-.. code-block:: c
-
- cur_tsc = rte_rdtsc();
-
- /*
- * TX burst queue drain
- */
-
- diff_tsc = cur_tsc - prev_tsc;
-
- if (unlikely(diff_tsc > drain_tsc)) {
- /* this could be optimized (use queueid instead of * portid), but it is not called so often */
-
- for (portid = 0; portid < RTE_MAX_ETHPORTS; portid++) {
- if (qconf->tx_mbufs[portid].len == 0)
- continue;
-
- lsi_send_burst(&lcore_queue_conf[lcore_id],
- qconf->tx_mbufs[portid].len, (uint8_t) portid);
- qconf->tx_mbufs[portid].len = 0;
- }
-
- /* if timer is enabled */
-
- if (timer_period > 0) {
- /* advance the timer */
-
- timer_tsc += diff_tsc;
-
- /* if timer has reached its timeout */
-
- if (unlikely(timer_tsc >= (uint64_t) timer_period)) {
- /* do this only on master core */
-
- if (lcore_id == rte_get_master_lcore()) {
- print_stats();
-
- /* reset the timer */
- timer_tsc = 0;
- }
- }
- }
- prev_tsc = cur_tsc;
- }
+.. literalinclude:: ../../../examples/link_status_interrupt/main.c
+ :language: c
+ :start-after: Draining TX queue in its main loop. 8<
+ :end-before: >8 End of draining TX queue in its main loop.
+ :dedent: 2