All of lore.kernel.org
 help / color / mirror / Atom feed
From: Subbaraya Sundeep <sbhatta@marvell.com>
To: <davem@davemloft.net>, <kuba@kernel.org>, <netdev@vger.kernel.org>
Cc: <sgoutham@marvell.com>, <hkelam@marvell.com>,
	<gakula@marvell.com>, Subbaraya Sundeep <sbhatta@marvell.com>
Subject: [net-next PATCH 06/11] octeontx2-pf: Sort the allocated MCAM entry indices
Date: Tue, 17 Aug 2021 10:14:48 +0530	[thread overview]
Message-ID: <1629175493-4895-7-git-send-email-sbhatta@marvell.com> (raw)
In-Reply-To: <1629175493-4895-1-git-send-email-sbhatta@marvell.com>

From: Sunil Goutham <sgoutham@marvell.com>

Per single mailbox request a maximum of 256 MCAM entries
can be allocated. If more than 256 are being allocated, then
the mcam indices in the final list could get jumbled. Hence
sort the indices.

Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
Signed-off-by: Subbaraya Sundeep <sbhatta@marvell.com>
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
index a0c4b73..96e1158 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
@@ -5,6 +5,7 @@
  */
 
 #include <net/ipv6.h>
+#include <linux/sort.h>
 
 #include "otx2_common.h"
 
@@ -61,6 +62,11 @@ static int otx2_free_ntuple_mcam_entries(struct otx2_nic *pfvf)
 	return 0;
 }
 
+static int mcam_entry_cmp(const void *a, const void *b)
+{
+	return *(u16 *)a - *(u16 *)b;
+}
+
 static int otx2_alloc_ntuple_mcam_entries(struct otx2_nic *pfvf, u16 count)
 {
 	struct otx2_flow_config *flow_cfg = pfvf->flow_cfg;
@@ -120,6 +126,15 @@ static int otx2_alloc_ntuple_mcam_entries(struct otx2_nic *pfvf, u16 count)
 			break;
 	}
 
+	/* Multiple MCAM entry alloc requests could result in non-sequential
+	 * MCAM entries in the flow_ent[] array. Sort them in an ascending order,
+	 * otherwise user installed ntuple filter index and MCAM entry index will
+	 * not be in sync.
+	 */
+	if (allocated)
+		sort(&flow_cfg->flow_ent[0], allocated,
+		     sizeof(flow_cfg->flow_ent[0]), mcam_entry_cmp, NULL);
+
 exit:
 	mutex_unlock(&pfvf->mbox.lock);
 
-- 
2.7.4


  parent reply	other threads:[~2021-08-17  4:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-17  4:44 [net-next PATCH 00/11] octeontx2: Rework MCAM flows management for VFs Subbaraya Sundeep
2021-08-17  4:44 ` [net-next PATCH 01/11] octeontx2-af: Modify install flow error codes Subbaraya Sundeep
2021-08-17  4:44 ` [net-next PATCH 02/11] octeontx2-af: add proper return codes for AF mailbox handlers Subbaraya Sundeep
2021-08-17  4:44 ` [net-next PATCH 03/11] octeontx2-af: Add debug messages for failures Subbaraya Sundeep
2021-08-17  4:44 ` [net-next PATCH 04/11] octeontx2-pf: Enable NETIF_F_RXALL support for VF driver Subbaraya Sundeep
2021-08-17  4:44 ` [net-next PATCH 05/11] octeontx2-pf: Ntuple filters support for VF netdev Subbaraya Sundeep
2021-08-17  4:44 ` Subbaraya Sundeep [this message]
2021-08-17  4:44 ` [net-next PATCH 07/11] octeontx2-pf: Unify flow management variables Subbaraya Sundeep
2021-08-17  4:44 ` [net-next PATCH 08/11] octeontx2-pf: devlink params support to set mcam entry count Subbaraya Sundeep
2021-08-17  4:44 ` [net-next PATCH 09/11] octeontx2-af: Allocate low priority entries for PF Subbaraya Sundeep
2021-08-17  4:44 ` [net-next PATCH 10/11] octeontx2-af: cn10K: Get NPC counters value Subbaraya Sundeep
2021-08-17  4:44 ` [net-next PATCH 11/11] octeontx2-af: configure npc for cn10k to allow packets from cpt Subbaraya Sundeep
2021-08-17  9:40 ` [net-next PATCH 00/11] octeontx2: Rework MCAM flows management for VFs patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1629175493-4895-7-git-send-email-sbhatta@marvell.com \
    --to=sbhatta@marvell.com \
    --cc=davem@davemloft.net \
    --cc=gakula@marvell.com \
    --cc=hkelam@marvell.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sgoutham@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.