From patchwork Fri Jan 5 23:54:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13512620 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44C73360B0 for ; Fri, 5 Jan 2024 23:54:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="CShuAdkq" Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-427f4407624so706761cf.3 for ; Fri, 05 Jan 2024 15:54:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1704498898; x=1705103698; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=HK2QFqPfaMzFix+5QTIBKxByrszzO7GRRgkLhawgCp8=; b=CShuAdkqRwWskg6fyDmMvL3xgRfg/w1WvTSmRwgIh0D0kjgbBdKVIt76Hua7H1rNXs hbwv2tWxFMdcWk0hi485fAs9inrNTHUAleD3x3dghk1L3s2XNMJ2a6aPr93+P0oPChUj 9nYx3/qStWNKCTID0uaMvviRvuj3Rb2dz5jqY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704498898; x=1705103698; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HK2QFqPfaMzFix+5QTIBKxByrszzO7GRRgkLhawgCp8=; b=GMAlDbBRVJDcinC8OiILNvUw7Y9kgDfDAMedTsNygjpkU6PVNnhGK3440Dv8Lk1lUo HFzpR6mykFkA61XEBq7RVlJoQnoofFLaRAz/S6LO1ygUc6QoLnuCvfEOS3RusZ9NjJDi Yr45wLnu04pYifDHiTcSCYPsG2osb9wFynuqLgKiqS1c1DMiuozMWlTcshg16jfAkbSf a6hQqvVvA67yy8EzMD36ST2RchQJfff8Ewm4HV0DgJdW3zHRYAJYMa5ezr4v/ka5aBFn dumCvRFeWeYUX/Bw3zCms3cyT8V3O2LJegceelwMxhj9XoStPCOy3hp8YEABqs+dR7QE SAOw== X-Gm-Message-State: AOJu0Yz1RA8G82ynrKq3HgyENgP6c4bhOtJ2DQCCc5N8EFiRZIScvf7b WZ4KYuzoY2o77wdyj+0IuyTy7M6TvnSN X-Google-Smtp-Source: AGHT+IHwdG36HKWBlgVrLAqUm91FFSJE7nOL0a/y8d8vNPdW45JxRBYxvl8jb7PRhuDynjPLZMqaLQ== X-Received: by 2002:a05:622a:1755:b0:428:4716:be75 with SMTP id l21-20020a05622a175500b004284716be75mr315298qtk.21.1704498898091; Fri, 05 Jan 2024 15:54:58 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id fb27-20020a05622a481b00b00427f0fdcd44sm1185612qtb.1.2024.01.05.15.54.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2024 15:54:57 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, horms@kernel.org Subject: [PATCH net-next 1/3] bnxt_en: Remove unneeded variable in bnxt_hwrm_clear_vnic_filter() Date: Fri, 5 Jan 2024 15:54:37 -0800 Message-Id: <20240105235439.28282-2-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240105235439.28282-1-michael.chan@broadcom.com> References: <20240105235439.28282-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org After recent refactoring, this function doesn't return error any more. Remove the unneeded rc variable and change the function to void. The caller is not checking for the return value. Fixes: 96c9bedc755e ("bnxt_en: Refactor L2 filter alloc/free firmware commands.") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202401041942.qrB1amZM-lkp@intel.com/ Signed-off-by: Michael Chan Reviewed-by: Simon Horman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index b70ddd33e9ed..fb5af8a34c8f 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -5752,10 +5752,9 @@ static int bnxt_hwrm_set_vnic_filter(struct bnxt *bp, u16 vnic_id, u16 idx, return rc; } -static int bnxt_hwrm_clear_vnic_filter(struct bnxt *bp) +static void bnxt_hwrm_clear_vnic_filter(struct bnxt *bp) { u16 i, j, num_of_vnics = 1; /* only vnic 0 supported */ - int rc = 0; /* Any associated ntuple filters will also be cleared by firmware. */ for (i = 0; i < num_of_vnics; i++) { @@ -5769,8 +5768,6 @@ static int bnxt_hwrm_clear_vnic_filter(struct bnxt *bp) } vnic->uc_filter_count = 0; } - - return rc; } #define BNXT_DFLT_TUNL_TPA_BMAP \ From patchwork Fri Jan 5 23:54:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13512621 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF681364AB for ; Fri, 5 Jan 2024 23:55:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="XgdpPoPf" Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-42836658198so590071cf.0 for ; Fri, 05 Jan 2024 15:55:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1704498899; x=1705103699; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=6Krmv7CmuXfl7DXk8aTDpoDj3ZUAd1H4d9ePlsNjgV4=; b=XgdpPoPfuLeBoykSDtvf4Y+4l07mtwejZOzlbfete81SI180V2M58LnPWWxxzN6RKR eQEqpHISkUduvK/ZA0E7ilg4X2h1SW/GKxasVGoB5z3XJ96ialzydq0ZFP02eEYK3Emk IbxpT5E6gCNryIHyjqUqiykCuLCoLfbixAfIg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704498899; x=1705103699; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=6Krmv7CmuXfl7DXk8aTDpoDj3ZUAd1H4d9ePlsNjgV4=; b=Hsf9vkfJuIv7yxfBJF6xbYb7rEczTL+pjyEDuYQLgAnQPIgPUXYKGk4ee41k4cb3J+ zdPHFUjhKNHXxD/3oMRkhLo96cd/nn8J3O/BSLLgWO3ePYNImJ8KOEvD8BJ/x5MgiDic jwPKn4+aZT6X1iRS++RDoak6D3DFOrDSJQocQCS5R6Ur/1Wn6X0qzNv3/w3B1KLKBOYp OHFm1h7zDAgHiXAU3ygWiw3WcfMxiv/d/QryN5yalM7R3TLBVpi51WQdTe88Bz7JBqdG 7R0jyr1TEi0VOlAQ/PqaHDGC/Rlfh8ixGYlNHPej/Fn8EgSaK3bAqZHc9jcgO+0gTsH6 T7dQ== X-Gm-Message-State: AOJu0YwjdgVqW2HCYszQ4k5AXk0X7gZQSBRXv18UshReWcedxLFFHK+7 q15f9sL+mLemCv5cQHZMaDd5kn6VwDD8 X-Google-Smtp-Source: AGHT+IHOGxl2DJ91VGKdocgJyX85wLVWWnTUncnToxFWx1KOeMiDmWFex6MMMftXmAAofw2rAtSUzA== X-Received: by 2002:ac8:7d88:0:b0:429:7b92:4dd8 with SMTP id c8-20020ac87d88000000b004297b924dd8mr284834qtd.91.1704498899436; Fri, 05 Jan 2024 15:54:59 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id fb27-20020a05622a481b00b00427f0fdcd44sm1185612qtb.1.2024.01.05.15.54.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2024 15:54:59 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, horms@kernel.org Subject: [PATCH net-next 2/3] bnxt_en: Fix RCU locking for ntuple filters in bnxt_srxclsrldel() Date: Fri, 5 Jan 2024 15:54:38 -0800 Message-Id: <20240105235439.28282-3-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240105235439.28282-1-michael.chan@broadcom.com> References: <20240105235439.28282-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org After looking up an ntuple filter from a RCU hash list, the rcu_read_unlock() call should be made after reading the structure, or after determining that the filter cannot age out (by aRFS). The existing code was calling rcu_read_unlock() too early in bnxt_srxclsrldel(). As suggested by Simon Horman, change the code to handle the error case of fltr_base not found in the if condition. The code looks cleaner this way. Fixes: 8d7ba028aa9a ("bnxt_en: Add support for ntuple filter deletion by ethtool.") Suggested-by: Simon Horman Reported-by: Jakub Kicinski Link: https://lore.kernel.org/netdev/20240104145955.5a6df702@kernel.org/ Signed-off-by: Michael Chan Reviewed-by: Simon Horman --- .../net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c index 5629ba9f4b2e..27b983c0a8a9 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c @@ -1345,25 +1345,26 @@ static int bnxt_srxclsrldel(struct bnxt *bp, struct ethtool_rxnfc *cmd) { struct ethtool_rx_flow_spec *fs = &cmd->fs; struct bnxt_filter_base *fltr_base; + struct bnxt_ntuple_filter *fltr; rcu_read_lock(); fltr_base = bnxt_get_one_fltr_rcu(bp, bp->ntp_fltr_hash_tbl, BNXT_NTP_FLTR_HASH_SIZE, fs->location); - if (fltr_base) { - struct bnxt_ntuple_filter *fltr; - - fltr = container_of(fltr_base, struct bnxt_ntuple_filter, base); + if (!fltr_base) { rcu_read_unlock(); - if (!(fltr->base.flags & BNXT_ACT_NO_AGING)) - return -EINVAL; - bnxt_hwrm_cfa_ntuple_filter_free(bp, fltr); - bnxt_del_ntp_filter(bp, fltr); - return 0; + return -ENOENT; } + fltr = container_of(fltr_base, struct bnxt_ntuple_filter, base); + if (!(fltr->base.flags & BNXT_ACT_NO_AGING)) { + rcu_read_unlock(); + return -EINVAL; + } rcu_read_unlock(); - return -ENOENT; + bnxt_hwrm_cfa_ntuple_filter_free(bp, fltr); + bnxt_del_ntp_filter(bp, fltr); + return 0; } static u64 get_ethtool_ipv4_rss(struct bnxt *bp) From patchwork Fri Jan 5 23:54:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13512622 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 071C8364B7 for ; Fri, 5 Jan 2024 23:55:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Xa+RmG7G" Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-4287791e09dso690391cf.2 for ; Fri, 05 Jan 2024 15:55:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1704498901; x=1705103701; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=w7wIZBkXxLJs2TL6ymRxvLKL1OMePhdREdeAC7t5pzw=; b=Xa+RmG7GU0dqacSthvB2mVJ3nDnmEKbOsYmbEaCuaQlzp4Cieuw9FQW/1a4qY0hiFi 6Cqd7/3+CjtlbzY3ghp/cHMeY/IvfyKehN3M9OiAZRaPShAEZEBWOOYZSwhak8Bv/kmU fxzdniV7DaupKTYsK6pKf6dlonN0gMJ3An9Mc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704498901; x=1705103701; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=w7wIZBkXxLJs2TL6ymRxvLKL1OMePhdREdeAC7t5pzw=; b=lw1aSbndMszjjcet+BVp6kPKC8JqdtkgLnc9URDfucHklfxq1xtE09RvnqrLgYA6nK znoSgufwy6ZY1IUVcAuTDLZ95VyXH9lORVbvf0BFcllVXNu485b27WZEfwkiwTic4cIB MVpGXzj4Vv9UgloxsqEgIuH31GMSQil71Y25wcFN+2/ieOr8JOryRrlqxnlp0LgwWczI MkvTWEl5T6YTHeyJKL4TL15kykiiZZyA8UaFBlKYhPKR/j4r4z9vxyRAQnRG/IAOxpwQ U7tXlNtUYi7uUmHkfDhoCe2K0HZ2fd/WRjj8JFZlWCUuLBks734EjokoyOmiob6S+fyI 3zhQ== X-Gm-Message-State: AOJu0YzqW5+ViNQa2e2B1xzbceUOWafxmh8XYsW6vUeMhCQkiHypt4is bzA9r5xoXz2T1v37Bm/HyelKkjWER9Z+ X-Google-Smtp-Source: AGHT+IEiGPkgnm92SezssqFyKr5z6wdty1aRE6jzJG9u7tPvdugIj5mek1QTUY1YaMiAbf+IjbTuZQ== X-Received: by 2002:ac8:57ce:0:b0:429:7d6b:4ff with SMTP id w14-20020ac857ce000000b004297d6b04ffmr299409qta.80.1704498900834; Fri, 05 Jan 2024 15:55:00 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id fb27-20020a05622a481b00b00427f0fdcd44sm1185612qtb.1.2024.01.05.15.54.59 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2024 15:55:00 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com, horms@kernel.org Subject: [PATCH net-next 3/3] bnxt_en: Fix RCU locking for ntuple filters in bnxt_rx_flow_steer() Date: Fri, 5 Jan 2024 15:54:39 -0800 Message-Id: <20240105235439.28282-4-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240105235439.28282-1-michael.chan@broadcom.com> References: <20240105235439.28282-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Similar to the previous patch, RCU locking was released too early in bnxt_rx_flow_steer(). Fix it to unlock after reading fltr->base.sw_id to guarantee that fltr won't be freed while we are still reading it. Fixes: cb5bdd292dc0 ("bnxt_en: Add bnxt_lookup_ntp_filter_from_idx() function") Reported-by: Simon Horman Link: https://lore.kernel.org/netdev/20231225165653.GH5962@kernel.org/ Signed-off-by: Michael Chan Reviewed-by: Simon Horman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index fb5af8a34c8f..0aacd3c6ed5c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -14020,8 +14020,8 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, rcu_read_lock(); fltr = bnxt_lookup_ntp_filter_from_idx(bp, new_fltr, idx); if (fltr) { - rcu_read_unlock(); rc = fltr->base.sw_id; + rcu_read_unlock(); goto err_free; } rcu_read_unlock();