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 C715B45AA5; Fri, 4 Oct 2024 03:05:39 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id AA31E40665; Fri, 4 Oct 2024 03:05:39 +0200 (CEST) Received: from mail-yb1-f202.google.com (mail-yb1-f202.google.com [209.85.219.202]) by mails.dpdk.org (Postfix) with ESMTP id 3C8A040665 for ; Fri, 4 Oct 2024 03:05:38 +0200 (CEST) Received: by mail-yb1-f202.google.com with SMTP id 3f1490d57ef6-e035949cc4eso2445493276.1 for ; Thu, 03 Oct 2024 18:05:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1728003937; x=1728608737; darn=dpdk.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=rzZ38K8KwbsDPud8OdmHx5OvqwGG/I3Nc1W9gLbNW54=; b=t99tGzcU0iyq6/UseeI6Y/XWxVpFvRyIxOWImBlRMHwKcRQjDlFXNgXMDxuhO/qG2V 1aQwU0tlrdWpVRXoYNc++lL3+6YrPnaXn2BKjNQ9iwRB3Cx84G7HWOIj46WRZqM0sjwZ ZrOSgBpSUGHofhSt3r64fd/iomLEev1gAWF2PzjkABnue7X61Bbq+LOr1V0bx6dS2EFW z8JM9z1Hxqe9Um/W7f+Bhs2jNELMudIcq2LKKp/1/qdFPCV6L/5LbDKJleXHFoX2loJX 1AIxXupZ13+eMVUZe+X27+Q5FdOsro2X7NylHRhrpGmgM5BoWZIlTkewoxOhPnokEtZw 8OtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728003937; x=1728608737; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=rzZ38K8KwbsDPud8OdmHx5OvqwGG/I3Nc1W9gLbNW54=; b=CG5OeYDPRy99iQ3AKKWttSiIhO+kzEvPH25hqioE1NZkqSIB8Wgarg4tX86ZDl5M1b 0eF9EZ0uYHzTwH6fofbelXTbf1o/MfwH29tlWXajZA6siK67rYyquu2RvJ9z7XNoruYw TNuDyh7ugrfhZT+PqTTzJ1BONeLeciJi4V5LOKSFVdiz0aw8cN+jKju99QNS5/TghpSZ sQt78uf8noG1IrhC1+xUAdZd6tUqWTUuHslqft/J80xAf7tH/RtnaunUO91rA2G7L+Hr PXxCoYALGKs24di8s3a41t4u5WAQ8GhRw3WrPoJUZXLKLXdMtF9MSGIpMjktEfN7q3EZ YEnQ== X-Gm-Message-State: AOJu0YxFbkujQQRd6lM+qI0z/vdBVNoNAZa4NjqYRaMq9ErN8u7ZpZ8l ioCWXtGDIsRvCy4e3RfSDqRktCuFA1AO7e0TUOS/iNYrs082Zh3OhW9VUyYgdb2lFuyFq5Q/iB8 dgC4b3fsQgQ== X-Google-Smtp-Source: AGHT+IHwExxludYmW0LXBsZmdYL9BWovzK9y6Knjyruktr1XWR2aRPjerAaknQRY891PW06aAobxYZatfkQm8w== X-Received: from joshwash.sea.corp.google.com ([2620:15c:11c:202:c808:ef77:413b:184d]) (user=joshwash job=sendgmr) by 2002:a05:6902:180a:b0:e25:e5b9:8114 with SMTP id 3f1490d57ef6-e28936d0652mr1936276.4.1728003937459; Thu, 03 Oct 2024 18:05:37 -0700 (PDT) Date: Thu, 3 Oct 2024 18:05:35 -0700 Mime-Version: 1.0 X-Mailer: git-send-email 2.47.0.rc0.187.ge670bccf7e-goog Message-ID: <20241004010535.239103-1-joshwash@google.com> Subject: [PATCH] net/gve: add IO memory barriers before reading descriptors From: Joshua Washington To: Jeroen de Borst , Rushil Gupta , Joshua Washington , Junfeng Guo Cc: dev@dpdk.org, stable@dpdk.org, Ferruh Yigit , Praveen Kaligineedi Content-Type: text/plain; charset="UTF-8" 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 Without memory barriers, there is no guarantee that the CPU will actually wait until after the descriptor has been fully written before loading descriptor data. In this case, it is possible that stale data is read and acted on by the driver when processing TX or RX completions. This change adds read memory barriers just after the generation bit is read in both the RX and the TX path to ensure that the NIC has properly passed ownership to the driver before descriptor data is read in full. Note that memory barriers should not be needed after writing the RX buffer queue/TX descriptor queue tails because rte_write32 includes an implicit write memory barrier. Fixes: 4022f9999f56 ("net/gve: support basic Tx data path for DQO") Fixes: 45da16b5b181 ("net/gve: support basic Rx data path for DQO") Cc: junfeng.guo@intel.com Cc: stable@dpdk.org Signed-off-by: Joshua Washington Reviewed-by: Praveen Kaligineedi Reviewed-by: Rushil Gupta --- drivers/net/gve/gve_rx_dqo.c | 2 ++ drivers/net/gve/gve_tx_dqo.c | 2 ++ 2 files changed, 4 insertions(+) diff --git a/drivers/net/gve/gve_rx_dqo.c b/drivers/net/gve/gve_rx_dqo.c index 5371bab77d..285c6ddd61 100644 --- a/drivers/net/gve/gve_rx_dqo.c +++ b/drivers/net/gve/gve_rx_dqo.c @@ -132,6 +132,8 @@ gve_rx_burst_dqo(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts) if (rx_desc->generation != rxq->cur_gen_bit) break; + rte_io_rmb(); + if (unlikely(rx_desc->rx_error)) { rxq->stats.errors++; continue; diff --git a/drivers/net/gve/gve_tx_dqo.c b/drivers/net/gve/gve_tx_dqo.c index 731c287224..6984f92443 100644 --- a/drivers/net/gve/gve_tx_dqo.c +++ b/drivers/net/gve/gve_tx_dqo.c @@ -24,6 +24,8 @@ gve_tx_clean_dqo(struct gve_tx_queue *txq) if (compl_desc->generation != txq->cur_gen_bit) return; + rte_io_rmb(); + compl_tag = rte_le_to_cpu_16(compl_desc->completion_tag); aim_txq = txq->txqs[compl_desc->id]; -- 2.47.0.rc0.187.ge670bccf7e-goog