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

Function main_loop

dpdk/examples/qos_meter/main.c:168–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

166
167
168static __rte_noreturn int
169main_loop(__rte_unused void *dummy)
170{
171 uint64_t current_time, last_time = rte_rdtsc();
172 uint32_t lcore_id = rte_lcore_id();
173
174 printf("Core %u: port RX = %d, port TX = %d\n", lcore_id, port_rx, port_tx);
175
176 while (1) {
177 uint64_t time_diff;
178 int i, nb_rx;
179
180 /* Mechanism to avoid stale packets in the output buffer */
181 current_time = rte_rdtsc();
182 time_diff = current_time - last_time;
183 if (unlikely(time_diff > TIME_TX_DRAIN)) {
184 /* Flush tx buffer */
185 rte_eth_tx_buffer_flush(port_tx, NIC_TX_QUEUE, tx_buffer);
186 last_time = current_time;
187 }
188
189 /* Read packet burst from NIC RX */
190 nb_rx = rte_eth_rx_burst(port_rx, NIC_RX_QUEUE, pkts_rx, RTE_MBUF_F_RX_BURST_MAX);
191
192 /* Handle packets */
193 for (i = 0; i < nb_rx; i ++) {
194 struct rte_mbuf *pkt = pkts_rx[i];
195
196 /* Handle current packet */
197 if (app_pkt_handle(pkt, current_time) == DROP)
198 rte_pktmbuf_free(pkt);
199 else
200 rte_eth_tx_buffer(port_tx, NIC_TX_QUEUE, tx_buffer, pkt);
201 }
202 }
203}
204
205static void
206print_usage(const char *prgname)

Callers

nothing calls this directly

Calls 8

rte_lcore_idFunction · 0.85
rte_eth_tx_buffer_flushFunction · 0.85
rte_eth_rx_burstFunction · 0.85
app_pkt_handleFunction · 0.85
rte_pktmbuf_freeFunction · 0.85
rte_eth_tx_bufferFunction · 0.85
rte_rdtscFunction · 0.50
printfFunction · 0.50

Tested by

no test coverage detected