From patchwork Sat Dec 23 04:22:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13503907 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (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 8DAEA6AB6 for ; Sat, 23 Dec 2023 04:22:46 +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="bpJo8FcO" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-67f8a5ed1a0so11117176d6.2 for ; Fri, 22 Dec 2023 20:22:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1703305365; x=1703910165; 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=mwYV0S7y9KO68Z7l2DMCEihNf5uZQ9U3SmO/Pc2JcT8=; b=bpJo8FcOJ5oeWjCf3rXGYA42FJFhmJ8bNCHLcuOC+4W8s0wjOcq9FFLrZ9m5RBpwEK IUu/g15TSXEY5rJ44uiDPIXXwQpZomG/IZCd85YemdLxiWpWjxdSy3ymkvictBxlwqze EdZb3IBlPY7fwtLdaQ12QPsVJntimO2pwDa6U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703305365; x=1703910165; 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=mwYV0S7y9KO68Z7l2DMCEihNf5uZQ9U3SmO/Pc2JcT8=; b=kQDQXPfet19xWVePlG5xgEbtnuyRQ8JeDsoPA69z9vQOforyB/ko0xCI2Tjki6LoWH 9Dl05gqswYOVrKh22GV9d5nhBChPEs2Di70vtuE93j6dd0F9TEAaYBX/WJgb+Nv6kjNj ZyhKaTCgIcRO/jlr6tWh7VtVDE8jwxwWDiOV5/rCO+6p4hCjGzPUpZtUEOokVbk9j692 sX28lcTQkZjy5FCWM13usLsLSWro5Au0hXJbssxUZYrxfaOJBYK2DMMpV93aPl3mziRj URdJTGCidWClhhXUVV95+79ai5LebR5mYkugbXKzrL+lN4fb6/HyHBRr2iVC6TA8O+FW OlrA== X-Gm-Message-State: AOJu0YxiNaEyJnX/YRHrdtBpg8jaCk0guSTPCZJ0qDdkuUHwg9pxu0ng xXWyC7WBrxSFH82EQbQGUtjg5/zL2hMH X-Google-Smtp-Source: AGHT+IG4NftX2vDYr/A6u0AlKZcvJJgfkI0158MBvHgXIUSmajmm/VP+HkUUCfa6yKC1IUQ1NkzZqA== X-Received: by 2002:a05:6214:caf:b0:67f:6b08:ec42 with SMTP id s15-20020a0562140caf00b0067f6b08ec42mr3850055qvs.25.1703305365471; Fri, 22 Dec 2023 20:22:45 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id ek5-20020ad45985000000b0067f8046a1acsm1299916qvb.144.2023.12.22.20.22.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Dec 2023 20:22:44 -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 Subject: [PATCH net-next v2 06/13] bnxt_en: Add bnxt_lookup_ntp_filter_from_idx() function Date: Fri, 22 Dec 2023 20:22:03 -0800 Message-Id: <20231223042210.102485-7-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231223042210.102485-1-michael.chan@broadcom.com> References: <20231223042210.102485-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 Add the helper function to look up the ntuple filter from the hash index and use it in bnxt_rx_flow_steer(). The helper function will also be used by user defined ntuple filters in the next patches. Reviewed-by: Andy Gospodarek Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan Reviewed-by: Simon Horman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 26 +++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index e9b382832a14..7027391316e5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -13899,6 +13899,21 @@ static bool bnxt_fltr_match(struct bnxt_ntuple_filter *f1, return false; } +static struct bnxt_ntuple_filter * +bnxt_lookup_ntp_filter_from_idx(struct bnxt *bp, + struct bnxt_ntuple_filter *fltr, u32 idx) +{ + struct bnxt_ntuple_filter *f; + struct hlist_head *head; + + head = &bp->ntp_fltr_hash_tbl[idx]; + hlist_for_each_entry_rcu(f, head, base.hash) { + if (bnxt_fltr_match(f, fltr)) + return f; + } + return NULL; +} + static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, u16 rxq_index, u32 flow_id) { @@ -13963,12 +13978,11 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, idx = bnxt_get_ntp_filter_idx(bp, fkeys, skb); head = &bp->ntp_fltr_hash_tbl[idx]; rcu_read_lock(); - hlist_for_each_entry_rcu(fltr, head, base.hash) { - if (bnxt_fltr_match(fltr, new_fltr)) { - rc = fltr->base.sw_id; - rcu_read_unlock(); - goto err_free; - } + fltr = bnxt_lookup_ntp_filter_from_idx(bp, new_fltr, idx); + if (fltr) { + rcu_read_unlock(); + rc = fltr->base.sw_id; + goto err_free; } rcu_read_unlock();