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 AAC9AA00BE for ; Tue, 15 Mar 2022 12:37:14 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9F9F0410FF; Tue, 15 Mar 2022 12:37:14 +0100 (CET) Received: from mail-lf1-f48.google.com (mail-lf1-f48.google.com [209.85.167.48]) by mails.dpdk.org (Postfix) with ESMTP id E2AD240150 for ; Mon, 14 Mar 2022 15:48:51 +0100 (CET) Received: by mail-lf1-f48.google.com with SMTP id n19so27553809lfh.8 for ; Mon, 14 Mar 2022 07:48:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l+HOx/hJQjoQf5DpiVLdK0I96bU566gpqt6CdDJmGi4=; b=KSJaU94VAVuFude8Sub4zYaMw1yjn6nN0B9jSDpPF3ud9kB/E7rlMoVomqeSbpvUTW cXY012ArNugqeqkwg7aJQHacBupK3YbAVY94qpt/9tu/3ouQGmuYhV2XTQvUPd365i6k IlMDR7vkwXRcL9yFvSG8RmCHDfFPauVaTTa2BwP+TbZoeyKvecJWqrE5XPfIG9Nsb+pe T6Q4A2A6smyzin4UMwaczr6pSi8aHYUfhob8e2gfrBnFQVNZNJwzk6yHmeJ/9M8WH7LK TGN8fF2MLB5LAVTC4pAuiNwOBszt3yiaUC5y9SgkVVovWYVFgac1WdITh8YuWzg3b8wQ U4xQ== 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:mime-version:content-transfer-encoding; bh=l+HOx/hJQjoQf5DpiVLdK0I96bU566gpqt6CdDJmGi4=; b=pTyrTzgWsO+Yx/WvlL5KtxV3p79Tv89JdMFwB7mTAe5+S7OnR53PJVOlzob55o+TIl wlEPA+M2tJb+e7NmbAF5DJpo29/SvPu/b5bdTIUz/UOL4QvgEPQCTaIG5aGZGKkv3xtW 2qRHuWOKb+SQ2pLe0N6PzfPHGl9Hkfn9o7TkutI8KAH4Dq8eX7NPIsesU1O3dFLBmJt3 Etr5tIXqa0wAJFBLDPI+1SRE1sUDDX/QhafiZcZeCwkc5LOCjHBHFWni5ADfpftUH3x4 mZ75FK0nGB9Ot94MvjqpPZVDkuXkLK4fEbzwCd7OjxE0nLHkoz6GViaTst7fXse8pPZe JLGw== X-Gm-Message-State: AOAM532r17NX3fwx/fGXz2jAR/zz8JHDvxa1DZH3qAhrcyArr54tXJSZ DaJx/g9+c5ax7D+MKReJySdeEEuzb93Kjg== X-Google-Smtp-Source: ABdhPJxJVRNwe2KWLP3sVWelT0HqNdscW+hKEGhtyIUmhR2UztZtxJuIcBVGqISQkJc76sD7Pa3Z1g== X-Received: by 2002:a05:6512:3402:b0:448:cd3:4b67 with SMTP id i2-20020a056512340200b004480cd34b67mr13443804lfr.294.1647269331299; Mon, 14 Mar 2022 07:48:51 -0700 (PDT) Received: from dgr-desktop.office.semihalf.net ([83.142.187.84]) by smtp.gmail.com with ESMTPSA id j15-20020a2e3c0f000000b00247e9bafa20sm4003518lja.99.2022.03.14.07.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Mar 2022 07:48:51 -0700 (PDT) From: Dawid Gorecki To: stable@dpdk.org Cc: Dawid Gorecki , Michal Krawczyk , Shai Brandes Subject: [PATCH 19.11 2/2] net/ena: fix reset reason being overwritten Date: Mon, 14 Mar 2022 15:42:36 +0100 Message-Id: <20220314144228.2475-2-dgr@semihalf.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220314144228.2475-1-dgr@semihalf.com> References: <20220314144228.2475-1-dgr@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailman-Approved-At: Tue, 15 Mar 2022 12:37:12 +0100 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [ upstream commit 2bae75eaa2e036020b726f61bc607a8f4142c3a8 ] When triggering the reset, no check was performed to see if the reset was already triggered. This could result in original reset reason being overwritten. Add ena_trigger_reset helper function, which checks if the reset was triggered and only sets the reset reason if the reset wasn't triggered yet. Replace all occurrences of manually setting the reset with ena_trigger_reset call. Fixes: 2081d5e2e92d ("net/ena: add reset routine") Cc: stable@dpdk.org Signed-off-by: Dawid Gorecki Reviewed-by: Michal Krawczyk Reviewed-by: Shai Brandes --- drivers/net/ena/ena_ethdev.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index dc30370a8f..818e1a179c 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -272,6 +272,15 @@ static const struct eth_dev_ops ena_dev_ops = { .reta_query = ena_rss_reta_query, }; +static inline void ena_trigger_reset(struct ena_adapter *adapter, + enum ena_regs_reset_reason_types reason) +{ + if (likely(!adapter->trigger_reset)) { + adapter->reset_reason = reason; + adapter->trigger_reset = true; + } +} + static inline void ena_rx_mbuf_prepare(struct rte_mbuf *mbuf, struct ena_com_rx_ctx *ena_rx_ctx) { @@ -378,8 +387,7 @@ static inline int validate_rx_req_id(struct ena_ring *rx_ring, uint16_t req_id) PMD_DRV_LOG(ERR, "Invalid rx req_id: %hu\n", req_id); - rx_ring->adapter->reset_reason = ENA_REGS_RESET_INV_RX_REQ_ID; - rx_ring->adapter->trigger_reset = true; + ena_trigger_reset(rx_ring->adapter, ENA_REGS_RESET_INV_RX_REQ_ID); ++rx_ring->rx_stats.bad_req_id; return -EFAULT; @@ -402,8 +410,7 @@ static int validate_tx_req_id(struct ena_ring *tx_ring, u16 req_id) /* Trigger device reset */ ++tx_ring->tx_stats.bad_req_id; - tx_ring->adapter->reset_reason = ENA_REGS_RESET_INV_TX_REQ_ID; - tx_ring->adapter->trigger_reset = true; + ena_trigger_reset(tx_ring->adapter, ENA_REGS_RESET_INV_TX_REQ_ID); return -EFAULT; } @@ -1574,8 +1581,7 @@ static void check_for_missing_keep_alive(struct ena_adapter *adapter) if (unlikely((rte_get_timer_cycles() - adapter->timestamp_wd) >= adapter->keep_alive_timeout)) { PMD_DRV_LOG(ERR, "Keep alive timeout\n"); - adapter->reset_reason = ENA_REGS_RESET_KEEP_ALIVE_TO; - adapter->trigger_reset = true; + ena_trigger_reset(adapter, ENA_REGS_RESET_KEEP_ALIVE_TO); ++adapter->dev_stats.wd_expired; } } @@ -1585,8 +1591,7 @@ static void check_for_admin_com_state(struct ena_adapter *adapter) { if (unlikely(!ena_com_get_admin_running_state(&adapter->ena_dev))) { PMD_DRV_LOG(ERR, "ENA admin queue is not in running state!\n"); - adapter->reset_reason = ENA_REGS_RESET_ADMIN_TO; - adapter->trigger_reset = true; + ena_trigger_reset(adapter, ENA_REGS_RESET_ADMIN_TO); } } @@ -2133,9 +2138,8 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, &ena_rx_ctx); if (unlikely(rc)) { PMD_DRV_LOG(ERR, "ena_com_rx_pkt error %d\n", rc); - rx_ring->adapter->reset_reason = - ENA_REGS_RESET_TOO_MANY_RX_DESCS; - rx_ring->adapter->trigger_reset = true; + ena_trigger_reset(rx_ring->adapter, + ENA_REGS_RESET_TOO_MANY_RX_DESCS); ++rx_ring->rx_stats.bad_desc_num; return 0; } -- 2.35.1