Re: [PATCH v4 net-next 2/3] octeontx2-af: Knobs for NPC default rule counters

From: Linu Cherian
Date: Mon Nov 04 2024 - 05:28:58 EST


Hi Jakub,

On 2024-11-04 at 01:23:10, Jakub Kicinski (kuba@xxxxxxxxxx) wrote:
> On Tue, 29 Oct 2024 09:27:38 +0530 Linu Cherian wrote:
> > + struct npc_install_flow_rsp rsp = { 0 };
>
> @rsp is reused in the loop, either it doesn't have to be inited at all,
> or it has to be inited before every use

Ack. It doesnt have to be inited. Will remove.

>
> > + struct npc_mcam *mcam = &rvu->hw->mcam;
> > + struct rvu_npc_mcam_rule *rule;
> > + int blkaddr;
> > +
> > + blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPC, 0);
> > + if (blkaddr < 0)
> > + return -EINVAL;
> > +
> > + mutex_lock(&mcam->lock);
> > + list_for_each_entry(rule, &mcam->mcam_rules, list) {
> > + if (!is_mcam_entry_enabled(rvu, mcam, blkaddr, rule->entry))
> > + continue;
> > + if (!rule->default_rule)
> > + continue;
> > + if (enable && !rule->has_cntr) { /* Alloc and map new counter */
> > + __rvu_mcam_add_counter_to_rule(rvu, rule->owner,
> > + rule, &rsp);
> > + if (rsp.counter < 0) {
> > + dev_err(rvu->dev, "%s: Err to allocate cntr for default rule (err=%d)\n",
> > + __func__, rsp.counter);
> > + break;
>
> shouldn't you "unwind" in this case? We'll leave the counter enabled
> for some rules and disabled for others


Wanted to keep a best effort approach here, will make it clear in the documentation.

>
> > + }
> > + npc_map_mcam_entry_and_cntr(rvu, mcam, blkaddr,
> > + rule->entry, rsp.counter);
> > + }
> > +
> > + if (enable && rule->has_cntr) /* Reset counter before use */ {
> > + rvu_write64(rvu, blkaddr,
> > + NPC_AF_MATCH_STATX(rule->cntr), 0x0);
> > + continue;
>
> so setting to enabled while already enabled resets the value?
> If so that's neither documented, nor.. usual.


Will move this code under, if (enable && !rule->has_cntr) case.
Infact, all enablement happens only from devlink control, hence the
above if check is really not required and can be confusing.

>
> > + }
> > +
> > + if (!enable && rule->has_cntr) /* Free and unmap counter */ {
> > + __rvu_mcam_remove_counter_from_rule(rvu, rule->owner,
> > + rule);
> > + }
>
> unnecesary parenthesis

Ack.


Thanks,
Linu Cherian.