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 900AEA0032; Fri, 1 Oct 2021 10:35:13 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 11F084067A; Fri, 1 Oct 2021 10:35:13 +0200 (CEST) Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) by mails.dpdk.org (Postfix) with ESMTP id 864D340040 for ; Fri, 1 Oct 2021 10:35:11 +0200 (CEST) Received: by mail-wr1-f51.google.com with SMTP id d26so14217726wrb.6 for ; Fri, 01 Oct 2021 01:35:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bw5Kzo6Ty8E5/vKKNSaEHM0w+0PX4iIn5N1u5hjByw0=; b=fDPQqDi6Vli219dijy/7xi96aD8Nt7tBxo2lMmEWsIdhVA8YGCxKUqzyiozyHnTOGw yXs1AQS5sSDQ/F86ikdCC/l2fLMsIXtpzc1wCIYdA2wDxQ1z2oAlFiQGgrandRrEODCZ iYT5xSHdYeCOlqbGGjdq5fjVS+D+XmdnCKeUucmrfXeJv2GhmoAiyJA+g+6F7M27SvYN ZAO8YIh1cNNb9Fruqjk9cYOlWkZUOWWnceGktj5lmbkIDGjQzY50yOOFxDECVXtl0eff du+n8aPuqBeovMr0544ipeeBoVWmpNkvgesloTbFbynNWwtgPrasMgQyfMyeQpbUhJ+t 9Z1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bw5Kzo6Ty8E5/vKKNSaEHM0w+0PX4iIn5N1u5hjByw0=; b=SwT3LOkvP6h/oZyHBiA0KcjCoKnXkXpu2kYsmzHUZ4WwRVkKuVfjb0Qbtb+C+rmFj6 XC+/LozZkiva3Uff0Wya5EQtrdyqK/OX2U2rgjUzJ7rMKf/C3GFa05tn5STuUQM0ZidV AUoyvqVUteA65Vxs8a+6L2h4dk56LokGH/6Za3Z71UpBf72UqCZIaGpECElLdGqg86W/ B0nJVyBHojvSgypuNELLdBkz4I3F0y6iihQtnfVADRgZfVN0jwAepphuYf5O8BgX78u5 ODK+Xd3gOfZo0bIPxty1hLscQE5BU4IhTDw5EzbG1qLL+AjzTwcg9L4nH8K+PiIy0tMt EsHw== X-Gm-Message-State: AOAM5301eLL38/jrqNwlZ14CbaKhWCHSeRFRjxzi8B3PZKf3lfp2GAhI JHc5n7+vGReH/O736erDnZU= X-Google-Smtp-Source: ABdhPJygXJdRUF9giPvtfEUV18LB4a+uw81CTnn/Pqgob7qaS8OsGAaO9YdComyg7MmREhsqtI451A== X-Received: by 2002:adf:e94d:: with SMTP id m13mr11127577wrn.28.1633077311307; Fri, 01 Oct 2021 01:35:11 -0700 (PDT) Received: from tucornea-dev-machine.localdomain ([193.226.172.43]) by smtp.gmail.com with ESMTPSA id r19sm4926431wmp.43.2021.10.01.01.35.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Oct 2021 01:35:10 -0700 (PDT) From: Tudor Cornea To: ferruh.yigit@intel.com Cc: stephen@networkplumber.org, linville@tuxdriver.com, andrew.rybchenko@oktetlabs.ru, thomas@monjalon.net, jerinj@marvell.com, dev@dpdk.org, Tudor Cornea Date: Fri, 1 Oct 2021 11:35:01 +0300 Message-Id: <1633077301-68561-1-git-send-email-tudor.cornea@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1632924497-60394-1-git-send-email-tudor.cornea@gmail.com> References: <1632924497-60394-1-git-send-email-tudor.cornea@gmail.com> Subject: [dpdk-dev] [PATCH v5] net/af_packet: 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" The af_packet pmd driver binds to a raw socket and allows sending and receiving of packets through the kernel. Since commit [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. Having the pmd driver support DEV_RX_OFFLOAD_VLAN_STRIP allows the application to control the desired vlan stripping behavior, until we have a way to describe offloads that can't be disabled by pmd drivers. This patch will cause a change in the default way that the af_packet pmd treats received vlan-tagged frames. While previously, the application was required to check the PKT_RX_VLAN_STRIPPED flag, after this patch, the pmd will re-insert the vlan tag transparently to the user, unless the DEV_RX_OFFLOAD_VLAN_STRIP is enabled in rxmode.offloads. I've attempted a preliminary benchmark to understand if the change could cause a sizable performance hit. Setup: Two virtual machines running on top of an ESXi hypervisor Tx: DPDK app (running on top of vmxnet3 PMD) Rx: af_packet (running on top of a kernel vmxnet3 interface) Packet size :68 (packet contains a vlan tag) Rates: Tx - 1.419 Mpps Rx (without vlan insertion) - 1227636 pps Rx (with vlan insertion) - 1220081 pps At a first glance, we don't seem to have a large degradation in terms of packet rate. [1] https://github.com/torvalds/linux/commit/bcc6d47903612c3861201cc3a866fb604f26b8b2 Signed-off-by: Tudor Cornea --- v5: * Updated the af_packet documentation * Updated the af_packet release notes v4: * Updated the af_packet documentation v3: * Updated release note and documentation * Updated commit with performance measurements v2: * Added DEV_RX_OFFLOAD_VLAN_STRIP to rxmode->offloads --- doc/guides/nics/af_packet.rst | 7 +++++++ doc/guides/rel_notes/release_21_11.rst | 5 +++++ drivers/net/af_packet/rte_eth_af_packet.c | 12 ++++++++++++ 3 files changed, 24 insertions(+) diff --git a/doc/guides/nics/af_packet.rst b/doc/guides/nics/af_packet.rst index efd6f1c..168a946 100644 --- a/doc/guides/nics/af_packet.rst +++ b/doc/guides/nics/af_packet.rst @@ -65,3 +65,10 @@ framecnt=512): .. code-block:: console --vdev=eth_af_packet0,iface=tap0,blocksz=4096,framesz=2048,framecnt=512,qpairs=1,qdisc_bypass=0 + +Features and Limitations of the af_packet PMD +--------------------------------------------- + +The PMD will re-insert the VLAN tag transparently to the packet +if the kernel strips it, as long as the ``DEV_RX_OFFLOAD_VLAN_STRIP`` is not +enabled by the application. diff --git a/doc/guides/rel_notes/release_21_11.rst b/doc/guides/rel_notes/release_21_11.rst index ad7c1af..3315703 100644 --- a/doc/guides/rel_notes/release_21_11.rst +++ b/doc/guides/rel_notes/release_21_11.rst @@ -66,6 +66,11 @@ New Features * Added rte_flow support for dual VLAN insert and strip actions. +* **Updated af_packet ethdev driver.** + + * Default VLAN strip behavior changed. + If previously, the VLAN tag was stripped by the kernel, if the application now requires the same behavior, it will need to enable ``DEV_RX_OFFLOAD_VLAN_STRIP``. + * **Updated Marvell cnxk crypto PMD.** * Added AES-CBC SHA1-HMAC support in lookaside protocol (IPsec) for CN10K. diff --git a/drivers/net/af_packet/rte_eth_af_packet.c b/drivers/net/af_packet/rte_eth_af_packet.c index b73b211..5ed9dd6 100644 --- a/drivers/net/af_packet/rte_eth_af_packet.c +++ b/drivers/net/af_packet/rte_eth_af_packet.c @@ -48,6 +48,7 @@ struct pkt_rx_queue { struct rte_mempool *mb_pool; uint16_t in_port; + uint8_t vlan_strip; volatile unsigned long rx_pkts; volatile unsigned long rx_bytes; @@ -78,6 +79,7 @@ struct pmd_internals { struct pkt_rx_queue *rx_queue; struct pkt_tx_queue *tx_queue; + uint8_t vlan_strip; }; static const char *valid_arguments[] = { @@ -148,6 +150,9 @@ 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); + + if (!pkt_q->vlan_strip && rte_vlan_insert(&mbuf)) + PMD_LOG(ERR, "Failed to reinsert VLAN tag"); } /* release incoming frame and advance ring buffer */ @@ -302,6 +307,11 @@ eth_dev_stop(struct rte_eth_dev *dev) static int eth_dev_configure(struct rte_eth_dev *dev __rte_unused) { + struct rte_eth_conf *dev_conf = &dev->data->dev_conf; + const struct rte_eth_rxmode *rxmode = &dev_conf->rxmode; + struct pmd_internals *internals = dev->data->dev_private; + + internals->vlan_strip = !!(rxmode->offloads & DEV_RX_OFFLOAD_VLAN_STRIP); return 0; } @@ -318,6 +328,7 @@ eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info) dev_info->min_rx_bufsize = 0; dev_info->tx_offload_capa = DEV_TX_OFFLOAD_MULTI_SEGS | DEV_TX_OFFLOAD_VLAN_INSERT; + dev_info->rx_offload_capa = DEV_RX_OFFLOAD_VLAN_STRIP; return 0; } @@ -448,6 +459,7 @@ eth_rx_queue_setup(struct rte_eth_dev *dev, dev->data->rx_queues[rx_queue_id] = pkt_q; pkt_q->in_port = dev->data->port_id; + pkt_q->vlan_strip = internals->vlan_strip; return 0; } -- 2.7.4