DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Tudor Cornea <tudor.cornea@gmail.com>, <linville@tuxdriver.com>
Cc: <thomas@monjalon.net>, <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH] net/af_packet: try to reinsert the stripped vlan tag
Date: Tue, 31 Aug 2021 16:31:20 +0100	[thread overview]
Message-ID: <1483bf7f-09ec-edd5-1fc1-4b4c81206ae2@intel.com> (raw)
In-Reply-To: <1629463607-76292-1-git-send-email-tudor.cornea@gmail.com>

On 8/20/2021 1:46 PM, Tudor Cornea wrote:
> The af_packet pmd driver binds to a raw socket and allows
> sending and receiving of packets through the kernel.
> 
> Since commit bcc6d47903 [1], the kernel strips the vlan tags early in
> __netif_receive_skb_core(), so we receive untagged packets while
> running with the af_packet pmd.
> 
> Luckily for us, the skb vlan-related fields are still populated from the
> stripped vlan tags, so we end up having all the information
> that we need in the mbuf.
> 
> We would like to have the the vlan tag inside the mbuf.
> Let's take a shot at it by trying to reinsert the stripped vlan tag.
> 

PMD already sets 'mbuf->vlan_tci' and 'PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED'
flags, so application can be aware of the vlan tag and can consume it.

Inserting the vlan tag back to packet is costly, what is the motivation to do so?

> As a side note, something similar was done for the netvsc pmd.
> 
> [1] https://github.com/torvalds/linux/commit/bcc6d47903612c3861201cc3a866fb604f26b8b2
> 
> Signed-off-by: Tudor Cornea <tudor.cornea@gmail.com>
> ---
>  drivers/net/af_packet/rte_eth_af_packet.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c
> index b73b211..d116583 100644
> --- a/drivers/net/af_packet/rte_eth_af_packet.c
> +++ b/drivers/net/af_packet/rte_eth_af_packet.c
> @@ -148,6 +148,10 @@ eth_af_packet_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
>  		if (ppd->tp_status & TP_STATUS_VLAN_VALID) {
>  			mbuf->vlan_tci = ppd->tp_vlan_tci;
>  			mbuf->ol_flags |= (PKT_RX_VLAN | PKT_RX_VLAN_STRIPPED);
> +
> +			/* the kernel always strips the vlan tag, try to reinsert it */
> +			if (rte_vlan_insert(&mbuf))
> +				PMD_LOG(ERR, "Failed to reinsert vlan tag");
>  		}
>  
>  		/* release incoming frame and advance ring buffer */
> 


  reply	other threads:[~2021-08-31 15:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-20 12:46 Tudor Cornea
2021-08-31 15:31 ` Ferruh Yigit [this message]
2021-09-01 19:07   ` Tudor Cornea
2021-09-01 21:34     ` Stephen Hemminger
2021-09-02 10:49       ` Ferruh Yigit
2021-09-03  9:45         ` Tudor Cornea
2021-09-08  8:59 ` [dpdk-dev] [PATCH v2] net/af_packet: " Tudor Cornea
2021-09-20 15:40   ` Ferruh Yigit
2021-09-21 20:59     ` Tudor Cornea
2021-09-24 11:44   ` [dpdk-dev] [PATCH v3] " Tudor Cornea
2021-09-24 15:10     ` Stephen Hemminger
2021-09-29 14:13       ` Tudor Cornea
2021-09-29 14:08     ` [dpdk-dev] [PATCH v4] " Tudor Cornea
2021-09-30  8:14       ` Ferruh Yigit
2021-10-01  8:49         ` Tudor Cornea
2021-10-01  8:35       ` [dpdk-dev] [PATCH v5] " Tudor Cornea
2021-10-01 15:02         ` Stephen Hemminger
2021-10-06  9:42           ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1483bf7f-09ec-edd5-1fc1-4b4c81206ae2@intel.com \
    --to=ferruh.yigit@intel.com \
    --cc=dev@dpdk.org \
    --cc=linville@tuxdriver.com \
    --cc=thomas@monjalon.net \
    --cc=tudor.cornea@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).