mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 18:21:24 +02:00
octeontx2-af: npc: cn20k: Allocate npc_priv and dstats dynamically.
Replace the file-scope static npc_priv with a kcalloc'd struct filled from hardware bank/subbank geometry at init (num_banks is no longer a const compile-time constant; drop init_done and use a non-NULL npc_priv pointer for liveness). Thread npc_priv_get() / pointer access through the CN20K NPC code paths, extend teardown to kfree the root struct on failure and in npc_cn20k_deinit, and adjust MCAM section setup to use the discovered subbank count. Allocate MCAM debugfs dstats via devm_kzalloc instead of a static matrix, and use the allocated backing store consistently when computing deltas (including the counter rollover compare). Signed-off-by: Ratheesh Kannoth <rkannoth@marvell.com> Link: https://patch.msgid.link/20260609040453.711932-10-rkannoth@marvell.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
parent
ad804b3250
commit
e1938b10fa
|
|
@ -176,7 +176,8 @@ static DEFINE_MUTEX(stats_lock);
|
|||
* hard limit on all silicon variants, preventing any possibility of
|
||||
* out-of-bounds access.
|
||||
*/
|
||||
static u64 dstats[MAX_NUM_BANKS][MAX_SUBBANK_DEPTH * MAX_NUM_SUB_BANKS] = {};
|
||||
static u64 (*dstats)[MAX_NUM_BANKS][MAX_SUBBANK_DEPTH * MAX_NUM_SUB_BANKS];
|
||||
|
||||
static int npc_mcam_dstats_show(struct seq_file *s, void *unused)
|
||||
{
|
||||
struct npc_priv_t *npc_priv;
|
||||
|
|
@ -212,24 +213,24 @@ static int npc_mcam_dstats_show(struct seq_file *s, void *unused)
|
|||
NPC_AF_CN20K_MCAMEX_BANKX_STAT_EXT(idx, bank));
|
||||
if (!stats)
|
||||
continue;
|
||||
if (stats == dstats[bank][idx])
|
||||
if (stats == dstats[0][bank][idx])
|
||||
continue;
|
||||
|
||||
if (stats < dstats[bank][idx])
|
||||
dstats[bank][idx] = 0;
|
||||
if (stats < dstats[0][bank][idx])
|
||||
dstats[0][bank][idx] = 0;
|
||||
|
||||
pf = 0xFFFF;
|
||||
map = xa_load(&npc_priv->xa_idx2pf_map, mcam_idx);
|
||||
if (map)
|
||||
pf = xa_to_value(map);
|
||||
|
||||
delta = stats - dstats[bank][idx];
|
||||
delta = stats - dstats[0][bank][idx];
|
||||
|
||||
snprintf(buff, sizeof(buff), "%u\t%#04x\t%llu\n",
|
||||
mcam_idx, pf, delta);
|
||||
seq_puts(s, buff);
|
||||
|
||||
dstats[bank][idx] = stats;
|
||||
dstats[0][bank][idx] = stats;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -397,6 +398,10 @@ int npc_cn20k_debugfs_init(struct rvu *rvu)
|
|||
debugfs_create_file("vidx2idx", 0444, rvu->rvu_dbg.npc,
|
||||
npc_priv, &npc_vidx2idx_map_fops);
|
||||
|
||||
dstats = devm_kzalloc(rvu->dev, sizeof(*dstats), GFP_KERNEL);
|
||||
if (!dstats)
|
||||
return -ENOMEM;
|
||||
|
||||
debugfs_create_file("dstats", 0444, rvu->rvu_dbg.npc, rvu,
|
||||
&npc_mcam_dstats_fops);
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -183,7 +183,6 @@ struct npc_defrag_show_node {
|
|||
* @xa_idx2pf_map: Mcam index to PF map.
|
||||
* @xa_pf_map: Pcifunc to index map.
|
||||
* @pf_cnt: Number of PFs.
|
||||
* @init_done: Indicates MCAM initialization is done.
|
||||
* @xa_pf2dfl_rmap: PF to default rule index map.
|
||||
* @xa_idx2vidx_map: Mcam index to virtual index map.
|
||||
* @xa_vidx2idx_map: virtual index to mcam index map.
|
||||
|
|
@ -195,7 +194,7 @@ struct npc_defrag_show_node {
|
|||
*/
|
||||
struct npc_priv_t {
|
||||
int bank_depth;
|
||||
const int num_banks;
|
||||
int num_banks;
|
||||
int num_subbanks;
|
||||
int subbank_depth;
|
||||
DECLARE_BITMAP(en_map, MAX_NUM_BANKS *
|
||||
|
|
@ -214,7 +213,6 @@ struct npc_priv_t {
|
|||
struct list_head defrag_lh;
|
||||
struct mutex lock; /* protect defrag nodes */
|
||||
int pf_cnt;
|
||||
bool init_done;
|
||||
};
|
||||
|
||||
struct npc_kpm_action0 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user