From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 8F1C3A0C45; Wed, 1 Sep 2021 23:34:26 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1EB2740DF7; Wed, 1 Sep 2021 23:34:26 +0200 (CEST) Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by mails.dpdk.org (Postfix) with ESMTP id D051C40140 for ; Wed, 1 Sep 2021 23:34:24 +0200 (CEST) Received: by mail-pj1-f50.google.com with SMTP id j1so525779pjv.3 for ; Wed, 01 Sep 2021 14:34:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Mbnnd5pFHLPQHRwOeb7Ca7J+2l8r87AN/8MBURKV3vA=; b=xcw9i2yT1VQI4IPFkATuGJ/wS9TdtcQ3VOjQNQrYpLgVZ/04ROdOwfrU2QId8aLyON 0zC15YhuBgQVdL7yhkFBq4YRKQK+ivqLhlkzkUoigDioRGAqMTiWt9kH7oi2/SlEfKHw 7YMHANk6LGVPHxBPzHKp241EZu7X20vq7VrLPCsBeJLW9AdX/xbRCIR0N8SVFws8mk/C SWSR0OKqRBCCItsMk+oh5HJqjx6ZNqzjqMPVpC/XFBf5/fnzlkcUC6rpQFYjzH507ryA TSU7KvQ4cHNuRW0d3DM6eboNvSn80LpI/0GF3W5ubb5xjSA+GSBoCbBxJRCiXRrtRYb5 zcow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mbnnd5pFHLPQHRwOeb7Ca7J+2l8r87AN/8MBURKV3vA=; b=MzDugAC/LpKdWnsZD/06pNt8TG2JvfkyTZzyOt4zROq62Qo3zpEz4Y8AJhPF3rQjt/ XLiOxx0USLx5494ouZHCMLqqGaENvfsphg9RDZsdtuccXczkbBk0p5xF7gaxICGbqFWG j75VqWaELVzHX/D2GLo9yqpv73/gBj8C/yM01c+Z2NFuBTvGgbERgWf66Z4FNcRDW+Sv aIjLckDpUxC5c+QFyQtRNhnWaPjnqCe8eZdrmeTsQxJ9JdQ9Qxu88s/OGH27x/jdA7UA 1++g61NTd8WvLptsNBRJ/x4PSZdiM6moSgWVGT0oe+LsltZB3EFGn/WpToKBVsK5CX6/ 1c4g== X-Gm-Message-State: AOAM533LZNox5QM5Rnmn73xuByMEZxs1xSr7sbr3UhDip0ySIJowMcbL V4Xhqhnoo6xnQoZWLTil7Gh2pA== X-Google-Smtp-Source: ABdhPJwWiDUV+xWk5MfaMh+n/aj6sjkdscdF36kKd4HriNn9yFPnQdOZOHFf1ZYwXUS/MWGWH2AXDA== X-Received: by 2002:a17:90a:f695:: with SMTP id cl21mr1408941pjb.220.1630532063841; Wed, 01 Sep 2021 14:34:23 -0700 (PDT) Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123]) by smtp.gmail.com with ESMTPSA id t18sm378413pfg.111.2021.09.01.14.34.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Sep 2021 14:34:23 -0700 (PDT) Date: Wed, 1 Sep 2021 14:34:20 -0700 From: Stephen Hemminger To: Tudor Cornea Cc: Ferruh Yigit , linville@tuxdriver.com, thomas@monjalon.net, dev@dpdk.org Message-ID: <20210901143420.5977fd9d@hermes.local> In-Reply-To: References: <1629463607-76292-1-git-send-email-tudor.cornea@gmail.com> <1483bf7f-09ec-edd5-1fc1-4b4c81206ae2@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] net/af_packet: try to reinsert the stripped vlan tag X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Wed, 1 Sep 2021 22:07:22 +0300 Tudor Cornea wrote: > Indeed, the vlan insertion could be a costly operation. We should probably > do it only if the user specifically asks to have the vlan tag in the packet. > Otherwise, af_packet PMD users might pay a price in terms of performance > for something they didn't ask for. > > I was thinking of avoiding having to change the application in order to > re-insert the vlan tag. > Doing this operation inside the PMD driver seemed like a good fit. > > Looking at the netvsc driver (drivers/net/netvsc), the vlan insertion is > guarded by a check to hv->vlan_strip > > if (!hv->vlan_strip && rte_vlan_insert(&m)) { > > hv->vlan_strip seems to be initialized in hn_dev_configure() in the > following way > > hv->vlan_strip = !!(rxmode->offloads & DEV_RX_OFFLOAD_VLAN_STRIP); > > while 'hv' seems to be stored in rte_eth_dev->data->dev_private > > I am thinking of doing something similar for the af_packet PMD. > The 'pmd_internals' structure could potentially hold a field, say > vlan_strip', which could be initialized if the application enables the > DEV_RX_OFFLOAD_VLAN_STRIP in rxmode->offloads > > This way, I'm thinking that the application could potentially control the > effect of vlan stripping for the af_packet PMD, in an uniform way, similar > to other PMDs. > Would this be considered an acceptable solution ? > > > > > On Tue, 31 Aug 2021 at 18:31, Ferruh Yigit wrote: > > > 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 The netvsc PMD has to handle some subtle cases where VLAN stripping is done by the VF but the slow path over vmbus does not. Since most traffic goes over the VF path, it makes sense for the netvsc PMD to advertise and handle VLAN stripping even if it has to do it in software. Ferruh is right the mbuf generated by current AF_PACKET PMD is valid with VLAN stripped correctly. I think you are also correct that the stripping needs to be controllable by the application. And yes the kernel always strips the VLAN; there is no option to tell socket(AF_PACKET) not to do that.