From patchwork Thu Dec 21 22:02:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13502685 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (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 6463178E96 for ; Thu, 21 Dec 2023 22:03:08 +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="iEZyTIbp" Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-67f09756761so7249376d6.3 for ; Thu, 21 Dec 2023 14:03:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1703196187; x=1703800987; 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=Vb1I1zcZo3kJ+opNRuVVS6d0xLRJyfpmk72i1AdN+uw=; b=iEZyTIbpfSGk1l6vN1k7H1W1JJ1OzsZNgomiuTbHwoV8hTW0JHd2g6xTRiU7mqD8UU jSqE4gxWr7KIX53WxbK9mYlepv35aUEaXpBZMecpoWhxdLGVhoqAOSMfGhxw4PSHVq0V PsOeqvFEfZBJvJyzEwFRgqKD/is+NB5PNY2Tc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703196187; x=1703800987; 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=Vb1I1zcZo3kJ+opNRuVVS6d0xLRJyfpmk72i1AdN+uw=; b=c1xNLgGIwiHb9CwJG/wVotcgVkCef24qGzszON4G9HwkxbOq5/eSrfY2Xvxa7c+Kiq x4nsg0yk2zhh71Ob0joX2dLOfseRXSiqBUy3yTwSSXilg3Hxx+3boOFlkgkcZhxXdwSI YrHJETZM3Mey8AysxpiH7k7a0qoVork2f5UQ0BbJYtY0zBvVCChBOHfAnFvnyq0HCuKN Xvtc8pwFD9iJgTw4bYn0Lmd1Mfk/iYXcQIevTQ3Yz6gZdGCE1b68mVfPyow2sAQnbJEd QCs5OfFWH6NsnErZo+idyimhXpzSZob/P38XWLH+IDibpM91UAZ2V2QcKPcAhKXI89nR CCHQ== X-Gm-Message-State: AOJu0YwYelx6UzFa4Rom8t8cry+yYuQgAxQbG/vGNSePuUAaKHKXSoXb APTfFX+p2ABYKkIQdNOm4+mnpuqipPYF X-Google-Smtp-Source: AGHT+IEXXEOJUjfEscUCtz2fEIj9UqQ7/w+8xLC0YUofF8UH1FJwCKFq8JgivnBzBtI7lpuCo9bx1Q== X-Received: by 2002:a05:6214:400c:b0:67f:3261:637c with SMTP id kd12-20020a056214400c00b0067f3261637cmr402722qvb.86.1703196187319; Thu, 21 Dec 2023 14:03:07 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id ee14-20020a0562140a4e00b0067f712874fbsm905198qvb.129.2023.12.21.14.03.05 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Dec 2023 14:03:06 -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 06/13] bnxt_en: Add bnxt_lookup_ntp_filter_from_idx() function Date: Thu, 21 Dec 2023 14:02:11 -0800 Message-Id: <20231221220218.197386-7-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231221220218.197386-1-michael.chan@broadcom.com> References: <20231221220218.197386-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 Signed-off-by: Michael Chan --- 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 66ec7d4d1398..267ffcffa2b4 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -13895,6 +13895,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) { @@ -13959,12 +13974,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();