On Tue, 10 Feb 2026 at 01:03, Stephen Hemminger
<[email protected]> wrote:
>
> Driver can easily insert VLAN tag strip and insertion similar
> to how it is handled in virtio and af_packet.
>
> Signed-off-by: Stephen Hemminger <[email protected]>
[snip]
> @@ -383,6 +393,56 @@ calculate_timestamp(struct timeval *ts) {
> }
> }
>
> +
Unneeded empty line.
> +/*
> + * If Vlan offload flag is present, insert the vlan.
> + * Returns the mbuf to send, or NULL on error.
> + */
> +static inline int
> +eth_pcap_tx_vlan(struct pcap_tx_queue *tx_queue, struct rte_mbuf **mbuf)
> +{
> + struct rte_mbuf *mb = *mbuf;
> +
> + if ((mb->ol_flags & RTE_MBUF_F_TX_VLAN) == 0)
> + return 0;
> +
> + if (unlikely(mb->data_len < RTE_ETHER_HDR_LEN)) {
> + PMD_TX_LOG(ERR, "mbuf missing ether header");
> + goto error;
> + }
> +
> + /* Need at another buffer to hold VLAN header? */
> + if (!RTE_MBUF_DIRECT(mb) || rte_mbuf_refcnt_read(mb) > 1) {
> + struct rte_mbuf *mh = rte_pktmbuf_alloc(mb->pool);
> + if (unlikely(mh == NULL)) {
> + PMD_TX_LOG(ERR, "mbuf pool exhausted on transmit
> vlan");
> + goto error;
> + }
> +
> + /* Extract original ethernet header into new mbuf */
> + memcpy(rte_pktmbuf_mtod(mh, void *), rte_pktmbuf_mtod(mb,
> void *), RTE_ETHER_HDR_LEN);
> + mh->nb_segs = mb->nb_segs + 1;
> + mh->data_len = RTE_ETHER_HDR_LEN;
> + mh->pkt_len = mb->pkt_len;
> + mh->ol_flags = mb->ol_flags;
> +
> + mb->data_len -= RTE_ETHER_HDR_LEN;
> + mh->next = mb;
> +
> + *mbuf = mh;
> + }
Could this segment allocation+chaining be moved in rte_vlan_insert?
This would help solve this issue in other sw drivers that currently
just drop (indirect) mbufs.
We might need an additional input param for driver that don't want
multiseg / existing users... ?
--
David Marchand