[RFC 2/4] test: add test for af_packet
Scott Mitchell
scott.k.mitch1 at gmail.com
Wed Jan 28 21:36:41 CET 2026
Awesome! Some suggestions below but could easily be done in a followup
for incremental progress.
> + /* TX burst */
> + nb_tx = rte_eth_tx_burst(port_id, 0, bufs, BURST_SIZE);
> +
> + /* Free any unsent mbufs */
> + for (i = nb_tx; i < BURST_SIZE; i++)
> + rte_pktmbuf_free(bufs[i]);
> +
> + /* Small delay to allow stats update */
> + rte_delay_us_block(1000);
Consider polling rte_eth_stats_get at a more frequent interval, break
when you see status update, and apply overall timeout/repeat limit ->
can make test more reliable and take less time when data is usually
available quickly
> + /* Try to receive packets (non-blocking) */
> + nb_rx = rte_eth_rx_burst(port_id, 0, bufs, BURST_SIZE);
> +
> + /* Free any received mbufs */
> + for (i = 0; i < nb_rx; i++)
> + rte_pktmbuf_free(bufs[i]);
> +
> + /* RX from tap interface without external traffic will return 0 */
> + /* This test just verifies the RX path doesn't crash */
Consider adding a test that round trips data (tx -> rx) to exercise
the read loop.
> + /* Get current MTU */
> + ret = rte_eth_dev_get_mtu(port_id, &mtu);
> + TEST_ASSERT(ret == 0, "Failed to get MTU");
> +
> + /* Try to set a smaller MTU */
> + ret = rte_eth_dev_set_mtu(port_id, 1400);
Consider getting the min/max supported MTU and setting it to verify it
works. My patch fixed some issues related to MTU and overhead of
frames that may have been caught by this.
> +
> + /* Reset stats */
> + ret = rte_eth_stats_reset(port_id);
> + TEST_ASSERT(ret == 0, "Failed to reset stats");
Consider enhancing to introduce multiple threads (writer and reader)
to replicate
> +static int
> +test_af_packet_multi_queue(void)
Consider sharing rx/tx logic in common functions for single/multi-queue cases.
More information about the dev
mailing list