Commit cc65fcab authored by Sunil Goutham's avatar Sunil Goutham Committed by David S. Miller

octeontx2-pf: Sort the allocated MCAM entry indices

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: default avatarSunil Goutham <sgoutham@marvell.com>
Signed-off-by: default avatarSubbaraya Sundeep <sbhatta@marvell.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3cffaed2
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
*/ */
#include <net/ipv6.h> #include <net/ipv6.h>
#include <linux/sort.h>
#include "otx2_common.h" #include "otx2_common.h"
...@@ -61,6 +62,11 @@ static int otx2_free_ntuple_mcam_entries(struct otx2_nic *pfvf) ...@@ -61,6 +62,11 @@ static int otx2_free_ntuple_mcam_entries(struct otx2_nic *pfvf)
return 0; 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) static int otx2_alloc_ntuple_mcam_entries(struct otx2_nic *pfvf, u16 count)
{ {
struct otx2_flow_config *flow_cfg = pfvf->flow_cfg; 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) ...@@ -120,6 +126,15 @@ static int otx2_alloc_ntuple_mcam_entries(struct otx2_nic *pfvf, u16 count)
break; 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: exit:
mutex_unlock(&pfvf->mbox.lock); mutex_unlock(&pfvf->mbox.lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment