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 502CCA034E for ; Tue, 22 Feb 2022 19:12:38 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5F3BD4120A; Tue, 22 Feb 2022 19:12:34 +0100 (CET) Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by mails.dpdk.org (Postfix) with ESMTP id 86A564120A for ; Tue, 22 Feb 2022 19:12:33 +0100 (CET) Received: by mail-ej1-f49.google.com with SMTP id a23so45288711eju.3 for ; Tue, 22 Feb 2022 10:12:33 -0800 (PST) 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=faFz5fnpmLmYycjNjq9xPGOX2yLI2Soxz8ybFQLWFbk=; b=fEXZOPzMvT57qJIVr/CB1miVlAAPTRL54iLIjKbtVHPt0HNt0SKcEbKJYWmLcni9mY vCoHaBe1/KoymKbQ3MjAurdBfsB4esVX2ilQzZbkE7M6z3dZEVuD8tHTtjj6liPzg8jI DWmBiUIjLL8XnOgcorL7jP3ugQtkRI+dYSMPBTVIeM5bDVEc+wfUeIohixKL9luLJ8MG vJaA2GsPreqDcR2sXLfMaNqN68bYLc7Sz6zUYW7bt7++bhEoz7rLWQYqnso7f5JePvTw S6m3kUciM37qXG4VLYcH6Jss5ZuNBZKn1moF7U28140u+84+JcJU4zpmmeRskplMLtuC jrwA== 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=faFz5fnpmLmYycjNjq9xPGOX2yLI2Soxz8ybFQLWFbk=; b=hJpTIRh8dDdyOUG3LOwj0++SAVStUmFxgEfHj5MJn1npX7KotYz+304lfyWVztdMeb +OVelOdiFBLl63xN7neRleKZVYiXWv1WA0QVYShdxJ8qhjmJROJHAXxSPspwiWc8yj3v YP29YlDAA3FSluhi8TjoojQ1Zcfmn+yCfWUNq9bwColw2TtOHGNUN/zAmWudvnbnFXJd ylCweGHMGOvuA/L44fIGLPsZjXyJ7SaMPH69SUbOq7ULD1JXt8kT5p9t29VjVdxlrScq +xaYtxu6fJRgBuXsZ0zsukSVgeYgL4G7PW1deERdSCtN5vKDfKB8H3oN4y4Vza44+L5+ +0yw== X-Gm-Message-State: AOAM532PwXGtbtN6O4OpOTagKYgNaF3kG13pe4RWQXrhlq789gkrQgHn g75lRiQAyy2LBBJyWX0wme9BnQ== X-Google-Smtp-Source: ABdhPJzs7kKECQ+jMNPwpVhCY3YPptc2NSRfYSXRVFpAR8NJVzQjkoFvCvIe1UAsvnGgl+amAjcY8g== X-Received: by 2002:a17:906:24cb:b0:6ce:b0a2:db5a with SMTP id f11-20020a17090624cb00b006ceb0a2db5amr20405421ejb.260.1645553553255; Tue, 22 Feb 2022 10:12:33 -0800 (PST) Received: from DESKTOP-U5LNN3J.localdomain (89-79-181-52.dynamic.chello.pl. [89.79.181.52]) by smtp.gmail.com with ESMTPSA id y21sm10610153eda.38.2022.02.22.10.12.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Feb 2022 10:12:32 -0800 (PST) From: Michal Krawczyk To: dev@dpdk.org Cc: shaibran@amazon.com, upstream@semihalf.com, Dawid Gorecki , stable@dpdk.org, Michal Krawczyk Subject: [PATCH v2 15/21] net/ena: check if reset was already triggered Date: Tue, 22 Feb 2022 19:11:40 +0100 Message-Id: <20220222181146.28882-16-mk@semihalf.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220222181146.28882-1-mk@semihalf.com> References: <20220222160634.24489-1-mk@semihalf.com> <20220222181146.28882-1-mk@semihalf.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 From: Dawid Gorecki 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 | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/drivers/net/ena/ena_ethdev.c b/drivers/net/ena/ena_ethdev.c index 0766f613b0..d413111b08 100644 --- a/drivers/net/ena/ena_ethdev.c +++ b/drivers/net/ena/ena_ethdev.c @@ -539,6 +539,15 @@ ENA_PROXY_DESC(ena_com_indirect_table_get, ENA_MP_IND_TBL_GET, }), struct ena_com_dev *ena_dev, u32 *ind_tbl); +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 ena_ring *rx_ring, struct rte_mbuf *mbuf, struct ena_com_rx_ctx *ena_rx_ctx, @@ -666,8 +675,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; } @@ -1783,8 +1791,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; } } @@ -1794,8 +1801,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); } } @@ -2606,14 +2612,13 @@ static uint16_t eth_ena_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, rc); if (rc == ENA_COM_NO_SPACE) { ++rx_ring->rx_stats.bad_desc_num; - rx_ring->adapter->reset_reason = - ENA_REGS_RESET_TOO_MANY_RX_DESCS; + ena_trigger_reset(rx_ring->adapter, + ENA_REGS_RESET_TOO_MANY_RX_DESCS); } else { ++rx_ring->rx_stats.bad_req_id; - rx_ring->adapter->reset_reason = - ENA_REGS_RESET_INV_RX_REQ_ID; + ena_trigger_reset(rx_ring->adapter, + ENA_REGS_RESET_INV_RX_REQ_ID); } - rx_ring->adapter->trigger_reset = true; return 0; } @@ -2978,9 +2983,8 @@ static int ena_xmit_mbuf(struct ena_ring *tx_ring, struct rte_mbuf *mbuf) if (unlikely(rc)) { PMD_DRV_LOG(ERR, "Failed to prepare Tx buffers, rc: %d\n", rc); ++tx_ring->tx_stats.prepare_ctx_err; - tx_ring->adapter->reset_reason = - ENA_REGS_RESET_DRIVER_INVALID_STATE; - tx_ring->adapter->trigger_reset = true; + ena_trigger_reset(tx_ring->adapter, + ENA_REGS_RESET_DRIVER_INVALID_STATE); return rc; } -- 2.25.1