Re: [EXT] Re: [net PATCH] octeontx2-pf: Fix graceful exit during PFC configuration failure

From: Simon Horman
Date: Mon Dec 18 2023 - 11:26:20 EST


On Sun, Dec 17, 2023 at 06:26:24AM +0000, Suman Ghosh wrote:

...

> >Perhaps I am on the wrong track here, but if
> >1. otx2_pfc_txschq_stop() was called by otx2_pfc_txschq_update()
> > (or otx2_pfc_txschq_config()) for relevant error cases; and
> >2. pfc_en was passed as a parameter to otx2_config_priority_flow_ctrl()
> >
> >Then I think that the unwind logic in the if condition above could
> >be expressed as unwind ladder with goto labels whereby the order
> >of unwinding is strictly the reverse of configuration.
> >
> >This is a subjective opinion, but the advantage of this approach is that
> >it
> >tends to lead to more maintainable code and fewer errors in... error
> >paths.
> >
> >(Completely untested!)
> >
> > ...
> > if (err)
> > goto err_pfc_en;
> > ...
> > err = otx2_pfc_txschq_update(pfvf);
> > if (err)
> > goto err_config;
> >
> > return 0;
> >
> >err_config:
> > if (pfc->pfc_en)
> > otx2_nix_config_bp(pfvf, false);
> > otx2_config_priority_flow_ctrl(pfvf, old_pfc_en);
> >err_pfc_en:
> > pfvf->pfc_en = old_pfc_en;
> >
> > return err;
> [Suman] Let me think through it. I need to check if some cases will be missed, will update, and push a new patch in that case. Thanks for your feedback, Simon!!

Thanks, much appreciated.