octeontx2-af: fix TX scheduler queue index width for CN20K
PATCH v2 1/1 octeontx2-af: fix TX scheduler queue index width for CN20K
From: Satha Rao <[email protected]>
CN20K supports up to 2K TX scheduler queues per layer, so scheduler queue index handling must use 11 bits.
Update TX scheduler queue index handling in both register-address decoding and hierarchy parent validation paths. Also widen TX scheduler register masking used by mailbox/config register access.
Without this, queue IDs above 1023 can be truncated on CN20K, which can cause invalid hierarchy validation and incorrect TX scheduler register access for higher queue indices.
---
v2: https://lore.kernel.org/netdev/[email protected]/
- Fix parent scheduler index decoding in hierarchy validation for CN20K.
- Add Fixes tags for the affected TX scheduler index/mask paths.
- Correct commit subject formatting (remove nested "Subject: [PATCH]" text).
--- drivers/net/ethernet/marvell/octeontx2/af/mbox.h | 2 +- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +1 -1
@@ -1164,7 +1164,7 @@ struct nix_txschq_config {u8 lvl;/* SMQ/MDQ/TL4/TL3/TL2/TL1 */ u8 read;#define TXSCHQ_IDX_SHIFT 16 -#define TXSCHQ_IDX_MASK (BIT_ULL(10) - 1) +#define TXSCHQ_IDX_MASK (BIT_ULL(11) - 1)#define TXSCHQ_IDX (reg, shift) (((reg) >> (shift)) & TXSCHQ_IDX_MASK)u8 num_regs;#define MAX_REGS_PER_MBOX_MSG 20
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +3 -3
@@ -2755,7 +2755,7 @@ static bool is_txschq_hierarchy_valid(struct rvu *rvu, u16 pcifunc, int blkaddr,if (!is_valid_txschq (rvu, blkaddr, lvl, pcifunc, schq))return false; - parent = (regval >>16 ) &0x1FF ; + parent = (regval >>16 ) & (is_cn20k (rvu->pdev) ?0x7FF :0x1FF );/* Validate MDQ's TL4 parent */ if (regbase ==NIX_AF_MDQX_PARENT (0 ) && !is_valid_txschq (rvu, blkaddr,NIX_TXSCH_LVL_TL4 , pcifunc, parent))
@@ -2849,9 +2849,9 @@ static void nix_tl1_default_cfg(struct rvu *rvu, struct nix_hw *nix_hw, }/* Register offset - [15:0] -* Scheduler Queue number - [25:16] +* Scheduler Queue number - [26:16] */ -#define NIX_TX_SCHQ_MASK GENMASK_ULL(25, 0) +#define NIX_TX_SCHQ_MASK GENMASK_ULL(26, 0) static int nix_txschq_cfg_read(struct rvu *rvu, struct nix_hw *nix_hw, int blkaddr, struct nix_txschq_config *req,
Signature · 1 line
2.25.1
[email protected]
AI reviewThis is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
Hi!
This is an automated message. This series looks like a fix, but its commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during development, syzbot report, manual code inspection, LLM or static analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical (e.g. found by LLM and not proven at runtime). If it was triggered please include the symptoms, like the stack trace or kernel messages.
- What hardware the change was tested on. For driver fixes please mention the device (and if relevant firmware version) used for testing, or say that the change was not tested on real hardware.
Please do not repost the series just to address the above. Instead, reply to this email with the missing information, so that reviewers can take it into account. If the series needs another revision for other reasons, please include the information in the commit messages then.
The evaluation is done by an LLM so it may be wrong, if you think that is the case please reply and explain.
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider.
Critical: 0 · High: 2 · Medium: 0 · Low: 2
If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough).
- [High] The fix is incomplete: on CN20K, the TX scheduler PARENT index is still cut to 9 bits in the SMQ flush hierarchy walk and in the…
- [High] octeontx2-af: username handle used in Signed-off-by trailer
- [Low] The Fixes tags point at commits that did not introduce the CN20K defect.
- [Low] The commit message is inaccurate about what the patch changes.
--
octeontx2-af: fix TX scheduler queue index width for CN20K
This commit widens TXSCHQ_IDX_MASK to 11 bits and NIX_TX_SCHQ_MASK to bits 26:0. On CN20K it also decodes the parent index in is_txschq_hierarchy_valid() with 11 bits. The goal is to support CN20K's up to 2K TX scheduler queues per level.
Quoted 3 lines
Without this, queue IDs above 1023 can be truncated on CN20K, which can cause invalid hierarchy validation and incorrect TX scheduler register access for higher queue indices.
[Severity: Low]
Is this description accurate? Before this patch, is_txschq_hierarchy_valid() masked the parent with 0x1FF. So parent indices above 511 were truncated, not only those above 1023.
On CN20K, the pre-patch effect also looks more like a bypass of the ownership check than invalid validation. A PF/VF could write parent = 512 + owned_index. is_valid_txschq() would then check owned_index, and the hardware would attach the queue to a parent the PF/VF might not own.
TXSCHQ_IDX_MASK in mbox.h and NIX_TX_SCHQ_MASK in rvu_nix.c are also widened on every silicon, not only on CN20K. On OcteonTX2/CN10K, a mailbox reg with bit 26 set used to be masked off and accepted. Now it decodes to schq >= 1024 and is rejected with NIX_AF_INVAL_TXSCHQ_CFG.
Could the commit message mention the 512 boundary, the ownership impact, and the mask change on all silicon?
Quoted 2 lines
Fixes b279bbb3314e ("octeontx2-af: NIX Tx scheduler queue config support")Fixes d06411632e80 ("octeontx2-af: enable tx shaping feature for 96xx C0")
[Severity: Low]
Are these the right commits to blame? Both were written for OcteonTX2 96xx, where the 10-bit index and 9-bit parent widths were correct. The patch itself keeps 0x1FF for non-CN20K silicon.
The fix also depends on is_cn20k(), which was added by commit 25d51ebf0f54f9 ("octeontx2: Set appropriate PF, VF masks and shifts based on silicon"). Stable trees picked from these tags go back to v4.20. There the patch would not build, and it would fix nothing because CN20K is not supported in those trees.
Should the tags point at the commit(s) that added CN20K NIX/TX scheduler support instead?
[ ... ]
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c static bool is_txschq_hierarchy_valid(struct rvu *rvu, u16 pcifunc, int blkaddr, · line 2758
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +1
-1@@ -2755,7 +2755,7 @@ static bool is_txschq_hierarchy_valid(struct rvu *rvu, u16 pcifunc, int blkaddr,if (!is_valid_txschq (rvu, blkaddr, lvl, pcifunc, schq))return false; - parent = (regval >>16 ) &0x1FF ; + parent = (regval >>16 ) & (is_cn20k (rvu->pdev) ?0x7FF :0x1FF );
[Severity: High]
The first Signed-off-by uses kmahammadraf, which is just the local part of the email address rather than a person's name. Documentation/process/submitting-patches.rst asks that the DCO be certified under a known identity. A handle copied from the address does not really say who is certifying the patch. Could this be respun with the contributor's name as they are normally known, for example "Firstname Lastname <[email protected]>"?
The trailer chain also looks inconsistent. The From: line credits Satha Rao as the author, but the mail was sent from [email protected] and that sign-off comes first. If kmahammadraf co-developed the change, a Co-developed-by tag is needed with it. If they are only handling the submission, their Signed-off-by should come after the author's.
[Severity: High]
Is this fix complete for CN20K? After this change, is_txschq_hierarchy_valid() accepts parents of 512 and above. But nix_smq_flush_fill_ctx() still decodes the same PARENT field with a 9-bit mask:
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c:nix_smq_flush_fill_ctx() {
...
/* get parent txsch node */
if (parent_off) {
regval = rvu_read64(rvu, blkaddr, parent_off);
schq = (regval >> 16) & 0x1FF;
}
...
}Take an MDQ whose TL4 parent is 600. The walk would continue from TL4 88, and every level above that would be read from an unrelated node.
nix_smq_flush() then uses this context in three places:
- nix_smq_flush_enadis_rate() zeroes CIR/PIR on the wrong MDQ/TL4/TL3/TL2/TL1 queues and later restores them. Those queues may belong to another PF/VF. The shapers on the real path stay armed.
- tl2_tl3_link_schq is taken from the truncated context. So NIX_AF_TL3_TL2X_LINKX_CFG[ENA] is cleared and set on an unrelated queue, and the real link stays enabled.
- nix_smq_flush_enadis_xoff() skips the wrong TL2 and matches PF_FUNC against pfvf_map[] of the wrong TL2. It can then XOFF TL2 queues it should leave alone.
Can the rvu_poll_reg() on SMQX_CFG bit 49 then time out with "SMQ flush failed"?
A PF/VF can reach this by writing NIX_AF_SMQX_CFG with BIT(49) set:
rvu_mbox_handler_nix_txschq_cfg()
nix_smq_flush()
nix_smq_flush_fill_ctx()
The same flush also runs on teardown through nix_txschq_free() and nix_txschq_free_one().
The shared masks in rvu_reg.h also keep their old widths:
#define NIX_AF_MDQ_PARENT_MASK GENMASK_ULL(24, 16) #define NIX_AF_TL4_PARENT_MASK GENMASK_ULL(23, 16) #define NIX_AF_TL3_PARENT_MASK GENMASK_ULL(23, 16) #define NIX_AF_TL2_PARENT_MASK GENMASK_ULL(20, 16)
print_tm_tree() in rvu_debugfs.c walks the parent chain with these masks. On CN20K it would read the PARENT registers of the wrong queues and print the wrong tree.
The commit message says this fixes "incorrect TX scheduler register access for higher queue indices". The same truncation seems to remain in these decoders, though.
Would a single silicon-aware PARENT field width shared by all of these decoders work better than an inline mask in is_txschq_hierarchy_valid()?
[ ... ]
Signature · 1 line
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112121907.2576520-1-kmahammadraf%40marvell.com