Re: [PATCH net] octeontx2-af: poll for TX link credits before link mode change
From: Ratheesh Kannoth
Date: Wed Aug 19 2026 - 00:39:35 EST
On 2026-08-18 at 13:08:48, Jagielski, Jedrzej (jedrzej.jagielski@xxxxxxxxx) wrote:
> From: Ratheesh Kannoth <rkannoth@xxxxxxxxxxx>
> Sent: Tuesday, August 18, 2026 5:37 AM
>
> >+int rvu_nix_tl1_xoff_wait_for_link_credits(struct rvu *rvu, u16 pcifunc)
> >+{
> >+ int link, blkaddr, count = 1000;
>
> count can be declared inside the loop as it's not used outside
> same for regval
historically the Linux kernel required declaring all variables at the beginning of a function or block.
>
> moreover defs instead of magic is always better choice
AFAIK, this is not a magic number but a counter.
Could you show me the Kernel coding guidilines which mandates this ?
>
> >+ u64 tx_credits, regval;
> >+ struct nix_hw *nix_hw;
> >+
> >+ blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NIX, pcifunc);
> >+ if (blkaddr < 0)
> >+ return NIX_AF_ERR_AF_LF_INVALID;
> >+
> >+ nix_hw = get_nix_hw(rvu->hw, blkaddr);
> >+ if (!nix_hw)
> >+ return NIX_AF_ERR_INVALID_NIXBLK;
> >+
> >+ /* set TL1 sw_xoff */
> >+ link = nix_get_tx_link(rvu, pcifunc);
> >+ rvu_write64(rvu, blkaddr, NIX_AF_TL1X_SW_XOFF(link), 1);
> >+
> >+ /* wait for link credits to return */
> >+ tx_credits = nix_hw->tx_credits[link];
> >+ while (1) {
>
> cant we use just for loop if this is simple cnt decrementing?
Do we see any advantage ?
>
> >+ regval = rvu_read64(rvu, blkaddr, NIX_AF_TX_LINKX_NORM_CREDIT(link));
> >+ if (((regval >> 12) & 0xFFFFF) == tx_credits)
>
> FIELD_GET(GENMASK(31, 12), regval) ?
ACK