[PATCH v20 12/25] net/pcap: support VLAN strip and insert offloads

Stephen Hemminger stephen at networkplumber.org
Tue Mar 24 17:47:29 CET 2026


On Mon, 16 Mar 2026 14:04:59 +0000
Bruce Richardson <bruce.richardson at intel.com> wrote:

> Are we sure this is the correct way to do this? To behave like a normal NIC
> the Tx VLAN tag should be inserted in the Tx function, rather than tx
> prepare should it not? There is no guarantee apps will call tx_prepare
> before Tx.
> 
> /Bruce

I wasn't sure, but copied what virtio PMD was doing.
If application is using VLAN's on virtio it would need to call prepare.

uint16_t
virtio_xmit_pkts_prepare(void *tx_queue __rte_unused, struct rte_mbuf **tx_pkts,
			uint16_t nb_pkts)
{
	uint16_t nb_tx;
	int error;

	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
		struct rte_mbuf *m = tx_pkts[nb_tx];

...
		/* Do VLAN tag insertion */
		if (unlikely(m->ol_flags & RTE_MBUF_F_TX_VLAN)) {
			error = rte_vlan_insert(&m);
			/* rte_vlan_insert() may change pointer
			 * even in the case of failure
			 */
			tx_pkts[nb_tx] = m;

			if (unlikely(error)) {
				rte_errno = -error;
				break;
			}
		}


More information about the dev mailing list