Add CN20K NIX and NPA contexts
Subsystems (4)
Subbaraya Sundeep
maintainerv3 cover Add CN20K NIX and NPA contexts
The hardware contexts of blocks NIX and NPA in CN20K silicon are different than that of previous silicons CN10K and CN9XK. This patchset adds the new contexts of CN20K in AF and PF drivers. A new mailbox for enqueuing contexts to hardware is added.
Patch 1 simplifies context writing and reading by using max context size supported by hardware instead of using each context size. Patch 2 and 3 adds NIX block contexts in AF driver and extends debugfs to display those new contexts
Patch 4 and 5 adds NPA block contexts in AF driver and extends debugfs to display those new contexts
Patch 6 omits NDC configuration since CN20K NPA does not use NDC for caching its contexts
Patch 7 and 8 uses the new NIX and NPA contexts in PF/VF driver. Patch 9, 10 and 11 are to support more bandwidth profiles present in CN20K for RX ratelimiting and to display new profiles in debugfs
v3 changes:
Added static_assert as suggested by Michal Swiatkowski
v2 changes:
Fixed string fortifier warnings by padding structures
Linu Cherian (4):
octeontx2-af: Add cn20k NPA block contexts
octeontx2-af: Extend debugfs support for cn20k NPA
octeontx2-af: Skip NDC operations for cn20k
octeontx2-pf: Initialize cn20k specific aura and pool contexts
Subbaraya Sundeep (7):
octeontx2-af: Simplify context writing and reading to hardware
octeontx2-af: Add cn20k NIX block contexts
octeontx2-af: Extend debugfs support for cn20k NIX
octeontx2-pf: Initialize new NIX SQ context for cn20k
octeontx2-af: Accommodate more bandwidth profiles for cn20k
octeontx2-af: Display new bandwidth profiles too in debugfs
octeontx2-pf: Use new bandwidth profiles in receive queue
.../ethernet/marvell/octeontx2/af/Makefile | 3 +- .../marvell/octeontx2/af/cn20k/debugfs.c | 216 ++++++++++++ .../marvell/octeontx2/af/cn20k/debugfs.h | 28 ++ .../ethernet/marvell/octeontx2/af/cn20k/nix.c | 20 ++ .../ethernet/marvell/octeontx2/af/cn20k/npa.c | 21 ++ .../marvell/octeontx2/af/cn20k/struct.h | 326 ++++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/mbox.h | 73 ++++ .../net/ethernet/marvell/octeontx2/af/rvu.h | 3 + .../marvell/octeontx2/af/rvu_debugfs.c | 39 ++- .../ethernet/marvell/octeontx2/af/rvu_nix.c | 67 ++-- .../ethernet/marvell/octeontx2/af/rvu_npa.c | 29 +- .../marvell/octeontx2/af/rvu_struct.h | 21 +- .../ethernet/marvell/octeontx2/nic/cn10k.c | 10 + .../ethernet/marvell/octeontx2/nic/cn20k.c | 212 +++++++++++- .../marvell/octeontx2/nic/otx2_common.c | 14 + .../marvell/octeontx2/nic/otx2_common.h | 10 + 16 files changed, 1038 insertions(+), 54 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.h create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/cn20k/nix.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/cn20k/npa.c
Signature · 1 line
2.34.1
Subbaraya Sundeep
maintainerPATCH v3 1/11 octeontx2-af: Simplify context writing and reading to hardware
Simplify NIX context reading and writing by using hardware maximum context size instead of using individual sizes of each context type.
--- .../ethernet/marvell/octeontx2/af/rvu_nix.c | 44 +++++++++---------- .../marvell/octeontx2/af/rvu_struct.h | 15 ++++++- 2 files changed, 36 insertions(+), 23 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +22 -22
@@ -1149,36 +1149,36 @@ static int rvu_nix_blk_aq_enq_inst(struct rvu *rvu, struct nix_hw *nix_hw,case NIX_AQ_INSTOP_WRITE :if (req->ctype ==NIX_AQ_CTYPE_RQ )memcpy (mask, &req->rq_mask, -sizeof (struct nix_rq_ctx_s )); +NIX_MAX_CTX_SIZE );else if (req->ctype ==NIX_AQ_CTYPE_SQ )memcpy (mask, &req->sq_mask, -sizeof (struct nix_sq_ctx_s )); +NIX_MAX_CTX_SIZE );else if (req->ctype ==NIX_AQ_CTYPE_CQ )memcpy (mask, &req->cq_mask, -sizeof (struct nix_cq_ctx_s )); +NIX_MAX_CTX_SIZE );else if (req->ctype ==NIX_AQ_CTYPE_RSS )memcpy (mask, &req->rss_mask, -sizeof (struct nix_rsse_s )); +NIX_MAX_CTX_SIZE );else if (req->ctype ==NIX_AQ_CTYPE_MCE )memcpy (mask, &req->mce_mask, -sizeof (struct nix_rx_mce_s )); +NIX_MAX_CTX_SIZE );else if (req->ctype ==NIX_AQ_CTYPE_BANDPROF )memcpy (mask, &req->prof_mask, -sizeof (struct nix_bandprof_s )); +NIX_MAX_CTX_SIZE ); fallthrough;case NIX_AQ_INSTOP_INIT :if (req->ctype ==NIX_AQ_CTYPE_RQ ) -memcpy (ctx, &req->rq,sizeof (struct nix_rq_ctx_s )); +memcpy (ctx, &req->rq,NIX_MAX_CTX_SIZE );else if (req->ctype ==NIX_AQ_CTYPE_SQ ) -memcpy (ctx, &req->sq,sizeof (struct nix_sq_ctx_s )); +memcpy (ctx, &req->sq,NIX_MAX_CTX_SIZE );else if (req->ctype ==NIX_AQ_CTYPE_CQ ) -memcpy (ctx, &req->cq,sizeof (struct nix_cq_ctx_s )); +memcpy (ctx, &req->cq,NIX_MAX_CTX_SIZE );else if (req->ctype ==NIX_AQ_CTYPE_RSS ) -memcpy (ctx, &req->rss,sizeof (struct nix_rsse_s )); +memcpy (ctx, &req->rss,NIX_MAX_CTX_SIZE );else if (req->ctype ==NIX_AQ_CTYPE_MCE ) -memcpy (ctx, &req->mce,sizeof (struct nix_rx_mce_s )); +memcpy (ctx, &req->mce,NIX_MAX_CTX_SIZE );else if (req->ctype ==NIX_AQ_CTYPE_BANDPROF ) -memcpy (ctx, &req->prof,sizeof (struct nix_bandprof_s )); +memcpy (ctx, &req->prof,NIX_MAX_CTX_SIZE );break ;case NIX_AQ_INSTOP_NOP :case NIX_AQ_INSTOP_READ :
@@ -1243,22 +1243,22 @@ static int rvu_nix_blk_aq_enq_inst(struct rvu *rvu, struct nix_hw *nix_hw,if (req->op ==NIX_AQ_INSTOP_READ ) {if (req->ctype ==NIX_AQ_CTYPE_RQ )memcpy (&rsp->rq, ctx, -sizeof (struct nix_rq_ctx_s )); +NIX_MAX_CTX_SIZE );else if (req->ctype ==NIX_AQ_CTYPE_SQ )memcpy (&rsp->sq, ctx, -sizeof (struct nix_sq_ctx_s )); +NIX_MAX_CTX_SIZE );else if (req->ctype ==NIX_AQ_CTYPE_CQ )memcpy (&rsp->cq, ctx, -sizeof (struct nix_cq_ctx_s )); +NIX_MAX_CTX_SIZE );else if (req->ctype ==NIX_AQ_CTYPE_RSS )memcpy (&rsp->rss, ctx, -sizeof (struct nix_rsse_s )); +NIX_MAX_CTX_SIZE );else if (req->ctype ==NIX_AQ_CTYPE_MCE )memcpy (&rsp->mce, ctx, -sizeof (struct nix_rx_mce_s )); +NIX_MAX_CTX_SIZE );else if (req->ctype ==NIX_AQ_CTYPE_BANDPROF )memcpy (&rsp->prof, ctx, -sizeof (struct nix_bandprof_s )); +NIX_MAX_CTX_SIZE ); } }
@@ -1289,8 +1289,8 @@ static int rvu_nix_verify_aq_ctx(struct rvu *rvu, struct nix_hw *nix_hw,/* Make copy of original context & mask which are required * for resubmission */ -memcpy (&aq_req.cq_mask, &req->cq_mask,sizeof (struct nix_cq_ctx_s )); -memcpy (&aq_req.cq, &req->cq,sizeof (struct nix_cq_ctx_s )); +memcpy (&aq_req.cq_mask, &req->cq_mask,NIX_MAX_CTX_SIZE ); +memcpy (&aq_req.cq, &req->cq,NIX_MAX_CTX_SIZE );/* exclude fields which HW can update */ aq_req.cq_mask.cq_err =0 ;
@@ -1309,7 +1309,7 @@ static int rvu_nix_verify_aq_ctx(struct rvu *rvu, struct nix_hw *nix_hw,* updated fields are masked out for request and response * comparison */ -for (word =0 ; word <sizeof (struct nix_cq_ctx_s ) /sizeof (u64); +for (word =0 ; word <NIX_MAX_CTX_SIZE /sizeof (u64); word++) { *(u64 *)((u8 *)&aq_rsp.cq + word *8 ) &= (*(u64 *)((u8 *)&aq_req.cq_mask + word *8 ));
@@ -1317,7 +1317,7 @@ static int rvu_nix_verify_aq_ctx(struct rvu *rvu, struct nix_hw *nix_hw, (*(u64 *)((u8 *)&aq_req.cq_mask + word *8 )); } -if (memcmp (&aq_req.cq, &aq_rsp.cq,sizeof (struct nix_cq_ctx_s ))) +if (memcmp (&aq_req.cq, &aq_rsp.cq,NIX_MAX_CTX_SIZE ))return NIX_AF_ERR_AQ_CTX_RETRY_WRITE ;return 0 ;
drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h +14 -1
@@ -13,6 +13,8 @@#define RVU_MULTI_BLK_VER 0x7ULL +#define NIX_MAX_CTX_SIZE 128 +/* RVU Block Address Enumeration */ enum rvu_block_addr_e {BLKADDR_RVUM =0x0ULL ,
@@ -370,8 +372,12 @@ struct nix_cq_ctx_s { u64 qsize : 4; u64 cq_err_int : 8; u64 cq_err_int_ena : 8; +/* Ensure all context sizes are minimum 128 bytes */ +u64 padding[12 ]; }; +static_assert (sizeof (struct nix_cq_ctx_s ) ==NIX_MAX_CTX_SIZE ); +/* CN10K NIX Receive queue context structure */ struct nix_cn10k_rq_ctx_s {u64 ena :1 ;
@@ -672,9 +678,12 @@ struct nix_sq_ctx_s {struct nix_rsse_s {uint32_t rq :20 ;uint32_t reserved_20_31 :12 ; - +/* Ensure all context sizes are minimum 128 bytes */ +u64 padding[15 ]; }; +static_assert (sizeof (struct nix_rsse_s ) ==NIX_MAX_CTX_SIZE ); +/* NIX receive multicast/mirror entry structure */ struct nix_rx_mce_s {uint64_t op :2 ;
@@ -684,8 +693,12 @@ struct nix_rx_mce_s { uint64_t rsvd_31_24 : 8; uint64_t pf_func : 16; uint64_t next : 16; +/* Ensure all context sizes are minimum 128 bytes */ +u64 padding[15 ]; }; +static_assert (sizeof (struct nix_rx_mce_s ) ==NIX_MAX_CTX_SIZE ); +enum nix_band_prof_layers {BAND_PROF_LEAF_LAYER =0 ,BAND_PROF_INVAL_LAYER =1 ,
Signature · 1 line
2.34.1
Subbaraya Sundeep
maintainerPATCH v3 5/11 octeontx2-af: Extend debugfs support for cn20k NPA
In reply to Subbaraya SundeepFrom: Linu Cherian <[email protected]>
Extend debugfs to display CN20K NPA aura and pool contexts.
--- .../marvell/octeontx2/af/cn20k/debugfs.c | 84 +++++++++++++++++++ .../marvell/octeontx2/af/cn20k/debugfs.h | 4 + .../marvell/octeontx2/af/rvu_debugfs.c | 10 +++ 3 files changed, 98 insertions(+)
drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.c +84 -0
@@ -130,3 +130,87 @@ void print_nix_cn20k_cq_ctx(struct seq_file *m,seq_printf (m,"W4: lbpid_ext \t\t\t\t%d\n\n" , cq_ctx->lbpid_ext);seq_printf (m,"W4: bpid_ext \t\t\t\t%d\n\n" , cq_ctx->bpid_ext); } + +void print_npa_cn20k_aura_ctx (struct seq_file *m, +struct npa_cn20k_aq_enq_rsp *rsp) +{ +struct npa_cn20k_aura_s *aura = &rsp->aura; + +seq_printf (m,"W0: Pool addr\t\t%llx\n" , aura->pool_addr); + +seq_printf (m,"W1: ena\t\t\t%d\nW1: pool caching\t%d\n" , + aura->ena, aura->pool_caching); +seq_printf (m,"W1: avg con\t\t%d\n" , aura->avg_con); +seq_printf (m,"W1: pool drop ena\t%d\nW1: aura drop ena\t%d\n" , + aura->pool_drop_ena, aura->aura_drop_ena); +seq_printf (m,"W1: bp_ena\t\t%d\nW1: aura drop\t\t%d\n" , + aura->bp_ena, aura->aura_drop); +seq_printf (m,"W1: aura shift\t\t%d\nW1: avg_level\t\t%d\n" , + aura->shift, aura->avg_level); + +seq_printf (m,"W2: count\t\t%llu\nW2: nix_bpid\t\t%d\n" , + (u64 )aura->count, aura->bpid); + +seq_printf (m,"W3: limit\t\t%llu\nW3: bp\t\t\t%d\nW3: fc_ena\t\t%d\n" , + (u64 )aura->limit, aura->bp, aura->fc_ena); + +seq_printf (m,"W3: fc_up_crossing\t%d\nW3: fc_stype\t\t%d\n" , + aura->fc_up_crossing, aura->fc_stype); +seq_printf (m,"W3: fc_hyst_bits\t%d\n" , aura->fc_hyst_bits); + +seq_printf (m,"W4: fc_addr\t\t%llx\n" , aura->fc_addr); + +seq_printf (m,"W5: pool_drop\t\t%d\nW5: update_time\t\t%d\n" , + aura->pool_drop, aura->update_time); +seq_printf (m,"W5: err_int \t\t%d\nW5: err_int_ena\t\t%d\n" , + aura->err_int, aura->err_int_ena); +seq_printf (m,"W5: thresh_int\t\t%d\nW5: thresh_int_ena \t%d\n" , + aura->thresh_int, aura->thresh_int_ena); +seq_printf (m,"W5: thresh_up\t\t%d\nW5: thresh_qint_idx\t%d\n" , + aura->thresh_up, aura->thresh_qint_idx); +seq_printf (m,"W5: err_qint_idx \t%d\n" , aura->err_qint_idx); + +seq_printf (m,"W6: thresh\t\t%llu\n" , (u64 )aura->thresh); +seq_printf (m,"W6: fc_msh_dst\t\t%d\n" , aura->fc_msh_dst); +} + +void print_npa_cn20k_pool_ctx (struct seq_file *m, +struct npa_cn20k_aq_enq_rsp *rsp) +{ +struct npa_cn20k_pool_s *pool = &rsp->pool; + +seq_printf (m,"W0: Stack base\t\t%llx\n" , pool->stack_base); + +seq_printf (m,"W1: ena \t\t%d\nW1: nat_align \t\t%d\n" , + pool->ena, pool->nat_align); +seq_printf (m,"W1: stack_caching\t%d\n" , + pool->stack_caching); +seq_printf (m,"W1: buf_offset\t\t%d\nW1: buf_size\t\t%d\n" , + pool->buf_offset, pool->buf_size); + +seq_printf (m,"W2: stack_max_pages \t%d\nW2: stack_pages\t\t%d\n" , + pool->stack_max_pages, pool->stack_pages); + +seq_printf (m,"W4: stack_offset\t%d\nW4: shift\t\t%d\nW4: avg_level\t\t%d\n" , + pool->stack_offset, pool->shift, pool->avg_level); +seq_printf (m,"W4: avg_con \t\t%d\nW4: fc_ena\t\t%d\nW4: fc_stype\t\t%d\n" , + pool->avg_con, pool->fc_ena, pool->fc_stype); +seq_printf (m,"W4: fc_hyst_bits\t%d\nW4: fc_up_crossing\t%d\n" , + pool->fc_hyst_bits, pool->fc_up_crossing); +seq_printf (m,"W4: update_time\t\t%d\n" , pool->update_time); + +seq_printf (m,"W5: fc_addr\t\t%llx\n" , pool->fc_addr); + +seq_printf (m,"W6: ptr_start\t\t%llx\n" , pool->ptr_start); + +seq_printf (m,"W7: ptr_end\t\t%llx\n" , pool->ptr_end); + +seq_printf (m,"W8: err_int\t\t%d\nW8: err_int_ena\t\t%d\n" , + pool->err_int, pool->err_int_ena); +seq_printf (m,"W8: thresh_int\t\t%d\n" , pool->thresh_int); +seq_printf (m,"W8: thresh_int_ena\t%d\nW8: thresh_up\t\t%d\n" , + pool->thresh_int_ena, pool->thresh_up); +seq_printf (m,"W8: thresh_qint_idx\t%d\nW8: err_qint_idx\t%d\n" , + pool->thresh_qint_idx, pool->err_qint_idx); +seq_printf (m,"W8: fc_msh_dst\t\t%d\n" , pool->fc_msh_dst); +}
drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.h +4 -0
@@ -20,5 +20,9 @@ void print_nix_cn20k_sq_ctx(struct seq_file *m, struct nix_cn20k_sq_ctx_s *sq_ctx);void print_nix_cn20k_cq_ctx (struct seq_file *m,struct nix_cn20k_aq_enq_rsp *rsp); +void print_npa_cn20k_aura_ctx (struct seq_file *m, +struct npa_cn20k_aq_enq_rsp *rsp); +void print_npa_cn20k_pool_ctx (struct seq_file *m, +struct npa_cn20k_aq_enq_rsp *rsp);#endif
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +10 -0
@@ -1038,6 +1038,11 @@ static void print_npa_aura_ctx(struct seq_file *m, struct npa_aq_enq_rsp *rsp)struct npa_aura_s *aura = &rsp->aura;struct rvu *rvu = m->private; +if (is_cn20k (rvu->pdev)) { +print_npa_cn20k_aura_ctx (m, (struct npa_cn20k_aq_enq_rsp *)rsp); +return ; + } +seq_printf (m,"W0: Pool addr\t\t%llx\n" , aura->pool_addr); seq_printf(m, "W1: ena\t\t\t%d\nW1: pool caching\t%d\n",
@@ -1086,6 +1091,11 @@ static void print_npa_pool_ctx(struct seq_file *m, struct npa_aq_enq_rsp *rsp)struct npa_pool_s *pool = &rsp->pool;struct rvu *rvu = m->private; +if (is_cn20k (rvu->pdev)) { +print_npa_cn20k_pool_ctx (m, (struct npa_cn20k_aq_enq_rsp *)rsp); +return ; + } +seq_printf (m,"W0: Stack base\t\t%llx\n" , pool->stack_base); seq_printf(m, "W1: ena \t\t%d\nW1: nat_align \t\t%d\n",
Signature · 1 line
2.34.1
Subbaraya Sundeep
maintainerPATCH v3 3/11 octeontx2-af: Extend debugfs support for cn20k NIX
In reply to Subbaraya SundeepExtend debugfs to display CN20K NIX send, receive and completion queue contexts.
--- .../ethernet/marvell/octeontx2/af/Makefile | 2 +- .../marvell/octeontx2/af/cn20k/debugfs.c | 132 ++++++++++++++++++ .../marvell/octeontx2/af/cn20k/debugfs.h | 24 ++++ .../marvell/octeontx2/af/rvu_debugfs.c | 17 +++ 4 files changed, 174 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.c create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.h
drivers/net/ethernet/marvell/octeontx2/af/Makefile +1 -1
@@ -12,4 +12,4 @@ rvu_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \ rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o rvu_npc_fs.o \ rvu_cpt.o rvu_devlink.o rpm.o rvu_cn10k.o rvu_switch.o \ rvu_sdp.o rvu_npc_hash.o mcs.o mcs_rvu_if.o mcs_cnf10kb.o \ - rvu_rep.o cn20k/mbox_init.o cn20k/nix.o + rvu_rep.o cn20k/mbox_init.o cn20k/nix.o cn20k/debugfs.o
drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.c new file +132 -0
132 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Marvell OcteonTx2 CGX driver +* +* Copyright (C) 2024 Marvell. +* +*/ + +#ifndef DEBUFS_H +#define DEBUFS_H + +#include <linux/fs.h> +#include <linux/debugfs.h> +#include <linux/module.h> +#include <linux/pci.h> + +#include "struct.h" +#include "../mbox.h" + +void print_nix_cn20k_sq_ctx (struct seq_file *m, +struct nix_cn20k_sq_ctx_s *sq_ctx); +void print_nix_cn20k_cq_ctx (struct seq_file *m, +struct nix_cn20k_aq_enq_rsp *rsp); + +#endif
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +17 -0
@@ -21,6 +21,8 @@#include "rvu_npc_hash.h" #include "mcs.h" +#include "cn20k/debugfs.h" +#define DEBUGFS_DIR_NAME "octeontx2"enum {
@@ -1944,10 +1946,16 @@ static void print_nix_sq_ctx(struct seq_file *m, struct nix_aq_enq_rsp *rsp)struct nix_hw *nix_hw = m->private;struct rvu *rvu = nix_hw->rvu; +if (is_cn20k (rvu->pdev)) { +print_nix_cn20k_sq_ctx (m, (struct nix_cn20k_sq_ctx_s *)sq_ctx); +return ; + } +if (!is_rvu_otx2 (rvu)) {print_nix_cn10k_sq_ctx (m, (struct nix_cn10k_sq_ctx_s *)sq_ctx);return ; } +seq_printf (m,"W0: sqe_way_mask \t\t%d\nW0: cq \t\t\t\t%d\n" , sq_ctx->sqe_way_mask, sq_ctx->cq); seq_printf(m, "W0: sdp_mcast \t\t\t%d\nW0: substream \t\t\t0x%03x\n",
@@ -2160,6 +2168,11 @@ static void print_nix_cq_ctx(struct seq_file *m, struct nix_aq_enq_rsp *rsp)struct nix_hw *nix_hw = m->private;struct rvu *rvu = nix_hw->rvu; +if (is_cn20k (rvu->pdev)) { +print_nix_cn20k_cq_ctx (m, (struct nix_cn20k_aq_enq_rsp *)rsp); +return ; + } +seq_printf (m,"W0: base \t\t\t%llx\n\n" , cq_ctx->base);seq_printf (m,"W1: wrptr \t\t\t%llx\n" , (u64 )cq_ctx->wrptr);
@@ -2189,6 +2202,7 @@ static void print_nix_cq_ctx(struct seq_file *m, struct nix_aq_enq_rsp *rsp) cq_ctx->cq_err_int_ena, cq_ctx->cq_err_int);seq_printf (m,"W3: qsize \t\t\t%d\nW3:caching \t\t\t%d\n" , cq_ctx->qsize, cq_ctx->caching); +seq_printf (m,"W3: substream \t\t\t0x%03x\nW3: ena \t\t\t%d\n" , cq_ctx->substream, cq_ctx->ena);if (!is_rvu_otx2 (rvu)) {
@@ -3791,6 +3805,9 @@ static void rvu_dbg_cpt_init(struct rvu *rvu, int blkaddr)static const char *rvu_get_dbg_dir_name (struct rvu *rvu) { +if (is_cn20k (rvu->pdev)) +return "cn20k" ; +if (!is_rvu_otx2 (rvu))return "cn10k" ;else
Signature · 1 line
2.34.1
Subbaraya Sundeep
maintainerPATCH v3 4/11 octeontx2-af: Add cn20k NPA block contexts
In reply to Subbaraya SundeepFrom: Linu Cherian <[email protected]>
New CN20K silicon has NPA hardware context structures different from previous silicons. Add NPA aura and pool context definitions for cn20k. Extend NPA context handling support to cn20k.
--- .../ethernet/marvell/octeontx2/af/Makefile | 3 +- .../ethernet/marvell/octeontx2/af/cn20k/npa.c | 21 +++ .../marvell/octeontx2/af/cn20k/struct.h | 130 ++++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/mbox.h | 35 +++++ 4 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/cn20k/npa.c
drivers/net/ethernet/marvell/octeontx2/af/Makefile +2 -1
@@ -12,4 +12,5 @@ rvu_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \ rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o rvu_npc_fs.o \ rvu_cpt.o rvu_devlink.o rpm.o rvu_cn10k.o rvu_switch.o \ rvu_sdp.o rvu_npc_hash.o mcs.o mcs_rvu_if.o mcs_cnf10kb.o \ - rvu_rep.o cn20k/mbox_init.o cn20k/nix.o cn20k/debugfs.o + rvu_rep.o cn20k/mbox_init.o cn20k/nix.o cn20k/debugfs.o \ + cn20k/npa.o
drivers/net/ethernet/marvell/octeontx2/af/cn20k/npa.c new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Marvell RVU Admin Function driver +* +* Copyright (C) 2024 Marvell. +* +*/ + +#include <linux/module.h> +#include <linux/pci.h> + +#include "struct.h" +#include "../rvu.h" + +int rvu_mbox_handler_npa_cn20k_aq_enq (struct rvu *rvu, +struct npa_cn20k_aq_enq_req *req, +struct npa_cn20k_aq_enq_rsp *rsp) +{ +return rvu_npa_aq_enq_inst (rvu, (struct npa_aq_enq_req *)req, + (struct npa_aq_enq_rsp *)rsp); +} +EXPORT_SYMBOL (rvu_mbox_handler_npa_cn20k_aq_enq);
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +130 -0
134 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +35 -0
@@ -203,6 +203,8 @@ M(NPA_LF_ALLOC, 0x400, npa_lf_alloc, \ M(NPA_LF_FREE, 0x401, npa_lf_free, msg_req, msg_rsp) \ M(NPA_AQ_ENQ, 0x402, npa_aq_enq, npa_aq_enq_req, npa_aq_enq_rsp) \ M(NPA_HWCTX_DISABLE, 0x403, npa_hwctx_disable, hwctx_disable_req, msg_rsp)\ +M (NPA_CN20K_AQ_ENQ ,0x404 , npa_cn20k_aq_enq, npa_cn20k_aq_enq_req, \ + npa_cn20k_aq_enq_rsp) \/* SSO/SSOW mbox IDs (range 0x600 - 0x7FF) */ \/* TIM mbox IDs (range 0x800 - 0x9FF) */ \/* CPT mbox IDs (range 0xA00 - 0xBFF) */ \
@@ -829,6 +831,39 @@ struct npa_aq_enq_rsp { }; }; +struct npa_cn20k_aq_enq_req { +struct mbox_msghdr hdr; +u32 aura_id; +u8 ctype; +u8 op; +union { +/* Valid when op == WRITE/INIT and ctype == AURA. +* LF fills the pool_id in aura.pool_addr. AF will translate +* the pool_id to pool context pointer. +*/ +struct npa_cn20k_aura_s aura; +/* Valid when op == WRITE/INIT and ctype == POOL */ +struct npa_cn20k_pool_s pool; + }; +/* Mask data when op == WRITE (1=write, 0=don't write) */ +union { +/* Valid when op == WRITE and ctype == AURA */ +struct npa_cn20k_aura_s aura_mask; +/* Valid when op == WRITE and ctype == POOL */ +struct npa_cn20k_pool_s pool_mask; + }; +}; + +struct npa_cn20k_aq_enq_rsp { +struct mbox_msghdr hdr; +union { +/* Valid when op == READ and ctype == AURA */ +struct npa_cn20k_aura_s aura; +/* Valid when op == READ and ctype == POOL */ +struct npa_cn20k_pool_s pool; + }; +}; +/* Disable all contexts of type 'ctype' */ struct hwctx_disable_req {struct mbox_msghdr hdr;
Signature · 1 line
2.34.1
Subbaraya Sundeep
maintainerPATCH v3 2/11 octeontx2-af: Add cn20k NIX block contexts
In reply to Subbaraya SundeepNew CN20K silicon has NIX hardware context structures different from previous silicons. Add NIX send and completion queue context definitions for cn20k. Extend NIX context handling support to cn20k.
--- .../ethernet/marvell/octeontx2/af/Makefile | 2 +- .../ethernet/marvell/octeontx2/af/cn20k/nix.c | 20 ++ .../marvell/octeontx2/af/cn20k/struct.h | 196 ++++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/mbox.h | 38 ++++ .../net/ethernet/marvell/octeontx2/af/rvu.h | 3 + .../ethernet/marvell/octeontx2/af/rvu_nix.c | 10 +- 6 files changed, 266 insertions(+), 3 deletions(-) create mode 100644 drivers/net/ethernet/marvell/octeontx2/af/cn20k/nix.c
drivers/net/ethernet/marvell/octeontx2/af/Makefile +1 -1
@@ -12,4 +12,4 @@ rvu_af-y := cgx.o rvu.o rvu_cgx.o rvu_npa.o rvu_nix.o \ rvu_reg.o rvu_npc.o rvu_debugfs.o ptp.o rvu_npc_fs.o \ rvu_cpt.o rvu_devlink.o rpm.o rvu_cn10k.o rvu_switch.o \ rvu_sdp.o rvu_npc_hash.o mcs.o mcs_rvu_if.o mcs_cnf10kb.o \ - rvu_rep.o cn20k/mbox_init.o + rvu_rep.o cn20k/mbox_init.o cn20k/nix.o
drivers/net/ethernet/marvell/octeontx2/af/cn20k/nix.c new file +20 -0
@@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Marvell RVU Admin Function driver +* +* Copyright (C) 2024 Marvell. +* +*/ + +#include <linux/module.h> +#include <linux/pci.h> + +#include "struct.h" +#include "../rvu.h" + +int rvu_mbox_handler_nix_cn20k_aq_enq (struct rvu *rvu, +struct nix_cn20k_aq_enq_req *req, +struct nix_cn20k_aq_enq_rsp *rsp) +{ +return rvu_nix_aq_enq_inst (rvu, (struct nix_aq_enq_req *)req, + (struct nix_aq_enq_rsp *)rsp); +}
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +196 -0
200 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +38 -0
@@ -336,6 +336,8 @@ M(NIX_MCAST_GRP_UPDATE, 0x802d, nix_mcast_grp_update, \ nix_mcast_grp_update_req, \ nix_mcast_grp_update_rsp) \ M(NIX_LF_STATS, 0x802e, nix_lf_stats, nix_stats_req, nix_stats_rsp) \ +M(NIX_CN20K_AQ_ENQ, 0x802f, nix_cn20k_aq_enq, nix_cn20k_aq_enq_req, \ + nix_cn20k_aq_enq_rsp) \/* MCS mbox IDs (range 0xA000 - 0xBFFF) */ \M (MCS_ALLOC_RESOURCES ,0xa000 , mcs_alloc_resources, mcs_alloc_rsrc_req, \ mcs_alloc_rsrc_rsp) \
@@ -935,6 +937,42 @@ struct nix_lf_free_req {u64 flags; }; +/* CN20K NIX AQ enqueue msg */ +struct nix_cn20k_aq_enq_req { +struct mbox_msghdr hdr; +u32 qidx; +u8 ctype; +u8 op; +union { +struct nix_cn20k_rq_ctx_s rq; +struct nix_cn20k_sq_ctx_s sq; +struct nix_cn20k_cq_ctx_s cq; +struct nix_rsse_s rss; +struct nix_rx_mce_s mce; +struct nix_bandprof_s prof; + }; +union { +struct nix_cn20k_rq_ctx_s rq_mask; +struct nix_cn20k_sq_ctx_s sq_mask; +struct nix_cn20k_cq_ctx_s cq_mask; +struct nix_rsse_s rss_mask; +struct nix_rx_mce_s mce_mask; +struct nix_bandprof_s prof_mask; + }; +}; + +struct nix_cn20k_aq_enq_rsp { +struct mbox_msghdr hdr; +union { +struct nix_cn20k_rq_ctx_s rq; +struct nix_cn20k_sq_ctx_s sq; +struct nix_cn20k_cq_ctx_s cq; +struct nix_rsse_s rss; +struct nix_rx_mce_s mce; +struct nix_bandprof_s prof; + }; +}; +/* CN10K NIX AQ enqueue msg */ struct nix_cn10k_aq_enq_req {struct mbox_msghdr hdr;
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +3 -0
@@ -1017,6 +1017,9 @@ int rvu_nix_mcast_update_mcam_entry(struct rvu *rvu, u16 pcifunc,void rvu_nix_flr_free_bpids (struct rvu *rvu,u16 pcifunc);int rvu_alloc_cint_qint_mem (struct rvu *rvu,struct rvu_pfvf *pfvf,int blkaddr,int nixlf); +int rvu_nix_aq_enq_inst (struct rvu *rvu,struct nix_aq_enq_req *req, +struct nix_aq_enq_rsp *rsp); +/* NPC APIs */ void rvu_npc_freemem (struct rvu *rvu);int rvu_npc_get_pkind (struct rvu *rvu,u16 pf);
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +8 -2
@@ -1019,6 +1019,12 @@ static void nix_get_aq_req_smq(struct rvu *rvu, struct nix_aq_enq_req *req, {struct nix_cn10k_aq_enq_req *aq_req; +if (is_cn20k (rvu->pdev)) { + *smq = ((struct nix_cn20k_aq_enq_req *)req)->sq.smq; + *smq_mask = ((struct nix_cn20k_aq_enq_req *)req)->sq_mask.smq; +return ; + } +if (!is_rvu_otx2 (rvu)) { aq_req = (struct nix_cn10k_aq_enq_req *)req; *smq = aq_req->sq.smq;
@@ -1323,8 +1329,8 @@ static int rvu_nix_verify_aq_ctx(struct rvu *rvu, struct nix_hw *nix_hw,return 0 ; } -static int rvu_nix_aq_enq_inst (struct rvu *rvu,struct nix_aq_enq_req *req, -struct nix_aq_enq_rsp *rsp) +int rvu_nix_aq_enq_inst (struct rvu *rvu,struct nix_aq_enq_req *req, +struct nix_aq_enq_rsp *rsp) {struct nix_hw *nix_hw;int err, retries =5 ;
Signature · 1 line
2.34.1
Subbaraya Sundeep
maintainerPATCH v3 6/11 octeontx2-af: Skip NDC operations for cn20k
In reply to Subbaraya SundeepFrom: Linu Cherian <[email protected]>
For cn20k, NPA block doesn't use the general purpose NDC (Near Coprocessor Bus Data cache Unit) for caching, hence skip the NDC related operations.
Also refactor NDC configuration code to a helper function.
--- .../marvell/octeontx2/af/rvu_debugfs.c | 3 ++ .../ethernet/marvell/octeontx2/af/rvu_npa.c | 29 ++++++++++++++----- 2 files changed, 24 insertions(+), 8 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +3 -0
@@ -2743,6 +2743,9 @@ static void rvu_dbg_npa_init(struct rvu *rvu) &rvu_dbg_npa_aura_ctx_fops);debugfs_create_file ("pool_ctx" ,0600 , rvu->rvu_dbg.npa, rvu, &rvu_dbg_npa_pool_ctx_fops); + +if (is_cn20k (rvu->pdev))/* NDC not appliable for cn20k */ +return ;debugfs_create_file ("ndc_cache" ,0600 , rvu->rvu_dbg.npa, rvu, &rvu_dbg_npa_ndc_cache_fops); debugfs_create_file("ndc_hits_miss", 0600, rvu->rvu_dbg.npa, rvu,
drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c +21 -8
@@ -464,6 +464,23 @@ int rvu_mbox_handler_npa_lf_free(struct rvu *rvu, struct msg_req *req,return 0 ; } +static void npa_aq_ndc_config (struct rvu *rvu,struct rvu_block *block) +{ +u64 cfg; + +if (is_cn20k (rvu->pdev))/* NDC not applicable to cn20k */ +return ; + +/* Do not bypass NDC cache */ + cfg =rvu_read64 (rvu, block->addr,NPA_AF_NDC_CFG ); + cfg &= ~0x03DULL ; +#ifdef CONFIG_NDC_DIS_DYNAMIC_CACHING +/* Disable caching of stack pages */ + cfg |=0x10ULL ; +#endif +rvu_write64 (rvu, block->addr,NPA_AF_NDC_CFG , cfg); +} +static int npa_aq_init (struct rvu *rvu,struct rvu_block *block) {u64 cfg;
@@ -479,14 +496,7 @@ static int npa_aq_init(struct rvu *rvu, struct rvu_block *block)rvu_write64 (rvu, block->addr,NPA_AF_GEN_CFG , cfg);#endif -/* Do not bypass NDC cache */ - cfg =rvu_read64 (rvu, block->addr,NPA_AF_NDC_CFG ); - cfg &= ~0x03DULL ; -#ifdef CONFIG_NDC_DIS_DYNAMIC_CACHING -/* Disable caching of stack pages */ - cfg |=0x10ULL ; -#endif -rvu_write64 (rvu, block->addr,NPA_AF_NDC_CFG , cfg); +npa_aq_ndc_config (rvu, block);/* For CN10K NPA BATCH DMA set 35 cache lines */ if (!is_rvu_otx2 (rvu)) {
@@ -567,6 +577,9 @@ int rvu_ndc_fix_locked_cacheline(struct rvu *rvu, int blkaddr)int bank, max_bank, line, max_line, err;u64 reg, ndc_af_const; +if (is_cn20k (rvu->pdev))/* NDC not applicable to cn20k */ +return 0 ; +/* Set the ENABLE bit(63) to '0' */ reg =rvu_read64 (rvu, blkaddr,NDC_AF_CAMS_RD_INTERVAL );rvu_write64 (rvu, blkaddr,NDC_AF_CAMS_RD_INTERVAL , reg &GENMASK_ULL (62 ,0 ));
Signature · 1 line
2.34.1
Subbaraya Sundeep
maintainerPATCH v3 7/11 octeontx2-pf: Initialize cn20k specific aura and pool contexts
In reply to Subbaraya SundeepFrom: Linu Cherian <[email protected]>
With new CN20K NPA pool and aura contexts supported in AF driver this patch modifies PF driver to use new NPA contexts. Implement new hw_ops for intializing aura and pool contexts for all the silicons.
--- .../ethernet/marvell/octeontx2/nic/cn10k.c | 4 + .../ethernet/marvell/octeontx2/nic/cn20k.c | 178 ++++++++++++++++-- .../marvell/octeontx2/nic/otx2_common.c | 14 ++ .../marvell/octeontx2/nic/otx2_common.h | 10 + 4 files changed, 195 insertions(+), 11 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c +4 -0
@@ -15,6 +15,8 @@ static struct dev_hw_ops otx2_hw_ops = { .aura_freeptr = otx2_aura_freeptr, .refill_pool_ptrs = otx2_refill_pool_ptrs, .pfaf_mbox_intr_handler = otx2_pfaf_mbox_intr_handler, + .aura_aq_init = otx2_aura_aq_init, + .pool_aq_init = otx2_pool_aq_init, };static struct dev_hw_ops cn10k_hw_ops = {
@@ -23,6 +25,8 @@ static struct dev_hw_ops cn10k_hw_ops = { .aura_freeptr = cn10k_aura_freeptr, .refill_pool_ptrs = cn10k_refill_pool_ptrs, .pfaf_mbox_intr_handler = otx2_pfaf_mbox_intr_handler, + .aura_aq_init = otx2_aura_aq_init, + .pool_aq_init = otx2_pool_aq_init, };void otx2_init_hw_ops (struct otx2_nic *pfvf)
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c +167 -11
187 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c +14 -0
@@ -1366,6 +1366,13 @@ void otx2_aura_pool_free(struct otx2_nic *pfvf)int otx2_aura_init (struct otx2_nic *pfvf,int aura_id,int pool_id,int numptrs) +{ +return pfvf->hw_ops->aura_aq_init (pfvf, aura_id, pool_id, + numptrs); +} + +int otx2_aura_aq_init (struct otx2_nic *pfvf,int aura_id, +int pool_id,int numptrs) {struct npa_aq_enq_req *aq;struct otx2_pool *pool;
@@ -1443,6 +1450,13 @@ int otx2_aura_init(struct otx2_nic *pfvf, int aura_id,int otx2_pool_init (struct otx2_nic *pfvf,u16 pool_id,int stack_pages,int numptrs,int buf_size,int type) +{ +return pfvf->hw_ops->pool_aq_init (pfvf, pool_id, stack_pages, numptrs, + buf_size, type); +} + +int otx2_pool_aq_init (struct otx2_nic *pfvf,u16 pool_id, +int stack_pages,int numptrs,int buf_size,int type) {struct page_pool_params pp_params = {0 };struct xsk_buff_pool *xsk_pool;
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +10 -0
@@ -14,6 +14,7 @@#include <linux/net_tstamp.h> #include <linux/ptp_clock_kernel.h> #include <linux/timecounter.h> +#include <linux/soc/marvell/silicons.h> #include <linux/soc/marvell/octeontx2/asm.h> #include <net/macsec.h> #include <net/pkt_cls.h>
@@ -374,6 +375,11 @@ struct dev_hw_ops {irqreturn_t (*pfaf_mbox_intr_handler)(int irq,void *pf_irq);irqreturn_t (*vfaf_mbox_intr_handler)(int irq,void *pf_irq);irqreturn_t (*pfvf_mbox_intr_handler)(int irq,void *pf_irq); +int (*aura_aq_init)(struct otx2_nic *pfvf,int aura_id, +int pool_id,int numptrs); +int (*pool_aq_init)(struct otx2_nic *pfvf,u16 pool_id, +int stack_pages,int numptrs,int buf_size, +int type); };#define CN10K_MCS_SA_PER_SC 4
@@ -1058,6 +1064,10 @@ irqreturn_t otx2_cq_intr_handler(int irq, void *cq_irq);int otx2_rq_init (struct otx2_nic *pfvf,u16 qidx,u16 lpb_aura);int otx2_cq_init (struct otx2_nic *pfvf,u16 qidx);int otx2_set_hw_capabilities (struct otx2_nic *pfvf); +int otx2_aura_aq_init (struct otx2_nic *pfvf,int aura_id, +int pool_id,int numptrs); +int otx2_pool_aq_init (struct otx2_nic *pfvf,u16 pool_id, +int stack_pages,int numptrs,int buf_size,int type);/* RSS configuration APIs*/ int otx2_rss_init (struct otx2_nic *pfvf);
Signature · 1 line
2.34.1
Subbaraya Sundeep
maintainerPATCH v3 8/11 octeontx2-pf: Initialize new NIX SQ context for cn20k
In reply to Subbaraya Sundeepcn20k has different NIX context for send queue hence use the new cn20k mailbox to init SQ context.
--- .../ethernet/marvell/octeontx2/nic/cn20k.c | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c +35 -1
@@ -389,11 +389,45 @@ static int cn20k_pool_aq_init(struct otx2_nic *pfvf, u16 pool_id,return 0 ; } +static int cn20k_sq_aq_init (void *dev,u16 qidx,u8 chan_offset,u16 sqb_aura) +{ +struct nix_cn20k_aq_enq_req *aq; +struct otx2_nic *pfvf = dev; + +/* Get memory to put this msg */ + aq =otx2_mbox_alloc_msg_nix_cn20k_aq_enq (&pfvf->mbox); +if (!aq) +return -ENOMEM ; + + aq->sq.cq = pfvf->hw.rx_queues + qidx; + aq->sq.max_sqe_size =NIX_MAXSQESZ_W16 ;/* 128 byte */ + aq->sq.cq_ena =1 ; + aq->sq.ena =1 ; + aq->sq.smq =otx2_get_smq_idx (pfvf, qidx); + aq->sq.smq_rr_weight =mtu_to_dwrr_weight (pfvf, pfvf->tx_max_pktlen); + aq->sq.default_chan = pfvf->hw.tx_chan_base + chan_offset; + aq->sq.sqe_stype =NIX_STYPE_STF ;/* Cache SQB */ + aq->sq.sqb_aura = sqb_aura; + aq->sq.sq_int_ena =NIX_SQINT_BITS ; + aq->sq.qint_idx =0 ; +/* Due pipelining impact minimum 2000 unused SQ CQE's +* need to maintain to avoid CQ overflow. +*/ + aq->sq.cq_limit = ((SEND_CQ_SKID *256 ) / (pfvf->qset.sqe_cnt)); + +/* Fill AQ info */ + aq->qidx = qidx; + aq->ctype =NIX_AQ_CTYPE_SQ ; + aq->op =NIX_AQ_INSTOP_INIT ; + +return otx2_sync_mbox_msg (&pfvf->mbox); +} +static struct dev_hw_ops cn20k_hw_ops = { .pfaf_mbox_intr_handler = cn20k_pfaf_mbox_intr_handler, .vfaf_mbox_intr_handler = cn20k_vfaf_mbox_intr_handler, .pfvf_mbox_intr_handler = cn20k_pfvf_mbox_intr_handler, - .sq_aq_init = cn10k_sq_aq_init, + .sq_aq_init = cn20k_sq_aq_init, .sqe_flush = cn10k_sqe_flush, .aura_freeptr = cn10k_aura_freeptr, .refill_pool_ptrs = cn10k_refill_pool_ptrs,
Signature · 1 line
2.34.1
Subbaraya Sundeep
maintainerPATCH v3 9/11 octeontx2-af: Accommodate more bandwidth profiles for cn20k
In reply to Subbaraya SundeepCN20K has 16k of leaf profiles, 2k of middle profiles and 256 of top profiles. This patch modifies existing receive queue and bandwidth profile context structures to accommodate additional profiles of cn20k.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 13 ++++++++----- .../net/ethernet/marvell/octeontx2/af/rvu_struct.h | 6 ++++-- 2 files changed, 12 insertions(+), 7 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +8 -5
@@ -5856,7 +5856,7 @@ static int nix_verify_bandprof(struct nix_cn10k_aq_enq_req *req,return -EINVAL ; ipolicer = &nix_hw->ipolicer[hi_layer]; - prof_idx = req->prof.band_prof_id; + prof_idx = req->prof.band_prof_id_h <<7 | req->prof.band_prof_id;if (prof_idx >= ipolicer->band_prof.max || ipolicer->pfvf_map[prof_idx] != pcifunc)return -EINVAL ;
@@ -6021,8 +6021,10 @@ static int nix_ipolicer_map_leaf_midprofs(struct rvu *rvu, aq_req->op =NIX_AQ_INSTOP_WRITE ; aq_req->qidx = leaf_prof; - aq_req->prof.band_prof_id = mid_prof; + aq_req->prof.band_prof_id = mid_prof &0x7F ; aq_req->prof_mask.band_prof_id =GENMASK (6 ,0 ); + aq_req->prof.band_prof_id_h = mid_prof >>7 ; + aq_req->prof_mask.band_prof_id_h =GENMASK (3 ,0 ); aq_req->prof.hl_en =1 ; aq_req->prof_mask.hl_en =1 ;
@@ -6062,7 +6064,7 @@ int rvu_nix_setup_ratelimit_aggr(struct rvu *rvu, u16 pcifunc,return 0 ;/* Get the bandwidth profile ID mapped to this RQ */ - leaf_prof = aq_rsp.rq.band_prof_id; + leaf_prof = aq_rsp.rq.band_prof_id_h <<10 | aq_rsp.rq.band_prof_id; ipolicer = &nix_hw->ipolicer[BAND_PROF_LEAF_LAYER ]; ipolicer->match_id[leaf_prof] = match_id;
@@ -6100,7 +6102,8 @@ int rvu_nix_setup_ratelimit_aggr(struct rvu *rvu, u16 pcifunc,* to different RQs and marked with same match_id * are rate limited in a aggregate fashion */ - mid_prof = aq_rsp.prof.band_prof_id; + mid_prof = aq_rsp.prof.band_prof_id_h <<7 | + aq_rsp.prof.band_prof_id; rc =nix_ipolicer_map_leaf_midprofs (rvu, nix_hw, &aq_req, &aq_rsp, leaf_prof, mid_prof);
@@ -6222,7 +6225,7 @@ static void nix_clear_ratelimit_aggr(struct rvu *rvu, struct nix_hw *nix_hw,if (!aq_rsp.prof.hl_en)return ; - mid_prof = aq_rsp.prof.band_prof_id; + mid_prof = aq_rsp.prof.band_prof_id_h <<7 | aq_rsp.prof.band_prof_id; ipolicer = &nix_hw->ipolicer[BAND_PROF_MID_LAYER ]; ipolicer->ref_count[mid_prof]--;/* If ref_count is zero, free mid layer profile */
drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h +4 -2
@@ -419,7 +419,8 @@ struct nix_cn10k_rq_ctx_s { u64 rsvd_171 : 1; u64 later_skip : 6; u64 xqe_imm_size : 6; - u64 rsvd_189_184 : 6; + u64 band_prof_id_h : 4; + u64 rsvd_189_188 : 2; u64 xqe_imm_copy : 1; u64 xqe_hdr_split : 1; u64 xqe_drop : 8; /* W3 */
@@ -749,7 +750,8 @@ struct nix_bandprof_s { uint64_t rc_action : 2; uint64_t meter_algo : 2; uint64_t band_prof_id : 7; - uint64_t reserved_111_118 : 8; + uint64_t band_prof_id_h : 4; + uint64_t reserved_115_118 : 4; uint64_t hl_en : 1; uint64_t reserved_120_127 : 8; uint64_t ts : 48; /* W2 */
Signature · 1 line
2.34.1
Subbaraya Sundeep
maintainerPATCH v3 10/11 octeontx2-af: Display new bandwidth profiles too in debugfs
In reply to Subbaraya SundeepConsider the new profiles of cn20k too while displaying bandwidth profile contexts in debugfs.
--- drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +7 -2
@@ -2056,7 +2056,9 @@ static void print_nix_cn10k_rq_ctx(struct seq_file *m,seq_printf (m,"W1: ipsecd_drop_ena \t\t%d\nW1: chi_ena \t\t\t%d\n\n" , rq_ctx->ipsecd_drop_ena, rq_ctx->chi_ena); -seq_printf (m,"W2: band_prof_id \t\t%d\n" , rq_ctx->band_prof_id); +seq_printf (m,"W2: band_prof_id \t\t%d\n" , + (u16 )rq_ctx->band_prof_id_h <<10 | rq_ctx->band_prof_id); +seq_printf (m,"W2: policer_ena \t\t%d\n" , rq_ctx->policer_ena);seq_printf (m,"W2: spb_sizem1 \t\t\t%d\n" , rq_ctx->spb_sizem1); seq_printf(m, "W2: wqe_skip \t\t\t%d\nW2: sqb_ena \t\t\t%d\n",
@@ -2574,7 +2576,10 @@ static void print_band_prof_ctx(struct seq_file *m, (prof->rc_action ==1 ) ?"DROP" :"RED" ;seq_printf (m,"W1: rc_action\t\t%s\n" , str);seq_printf (m,"W1: meter_algo\t\t%d\n" , prof->meter_algo); -seq_printf (m,"W1: band_prof_id\t%d\n" , prof->band_prof_id); + +seq_printf (m,"W1: band_prof_id\t%d\n" , + (u16 )prof->band_prof_id_h <<7 | prof->band_prof_id); +seq_printf (m,"W1: hl_en\t\t%d\n" , prof->hl_en);seq_printf (m,"W2: ts\t\t\t%lld\n" , (u64 )prof->ts);
Signature · 1 line
2.34.1
Subbaraya Sundeep
maintainerPATCH v3 11/11 octeontx2-pf: Use new bandwidth profiles in receive queue
In reply to Subbaraya SundeepReceive queue points to a bandwidth profile for rate limiting. Since cn20k has additional bandwidth profiles use them too while mapping receive queue to bandwidth profile.
--- drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/net/ethernet/marvell/octeontx2/nic/cn10k.c +6 -0
@@ -341,6 +341,12 @@ int cn10k_map_unmap_rq_policer(struct otx2_nic *pfvf, int rq_idx, aq->rq.band_prof_id = policer; aq->rq_mask.band_prof_id =GENMASK (9 ,0 ); +/* If policer id is greater than 1023 then it implies hardware supports +* more leaf profiles. In that case use band_prof_id_h for 4 MSBs. +*/ + aq->rq.band_prof_id_h = policer >>10 ; + aq->rq_mask.band_prof_id_h =GENMASK (3 ,0 ); +/* Fill AQ info */ aq->qidx = rq_idx; aq->ctype =NIX_AQ_CTYPE_RQ ;
Signature · 1 line
2.34.1
Jakub Kicinski
maintainerRe: [net-next PATCH v3 07/11] octeontx2-pf: Initialize cn20k specific aura and pool contexts
In reply to Subbaraya Sundeepdrivers/net/ethernet/marvell/octeontx2/nic/cn20k.c int cn20k_register_pfvf_mbox_intr(struct otx2_nic *pf, int numvfs) · line 377
Quoted 2 lines · On Thu, 17 Jul 2025 22:37:39 +0530 Subbaraya Sundeep wrote:
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c +2
-0+ sz =ALIGN (ALIGN (SKB_DATA_ALIGN (buf_size),OTX2_ALIGN ),PAGE_SIZE ); + pp_params.order = (sz /PAGE_SIZE ) -1 ;
This doesn't look right - order means log2(), not page count
Signature · 1 line
pw-bot: cr
Simon Horman
reviewerRe: [net-next PATCH v3 01/11] octeontx2-af: Simplify context writing and reading to hardware
In reply to Subbaraya SundeepQuoted 5 lines · Subbaraya Sundeep
Simplify NIX context reading and writing by using hardware maximum context size instead of using individual sizes of each context type.
Signed-off-by Subbaraya Sundeep <[email protected]>
...
Quoted 14 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h +2
-0@@ -13,6 +13,8 @@#define RVU_MULTI_BLK_VER 0x7ULL +#define NIX_MAX_CTX_SIZE 128 +/* RVU Block Address Enumeration */ enum rvu_block_addr_e {BLKADDR_RVUM =0x0ULL ,
drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h struct nix_cq_ctx_s { · line 375
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h +1
-0@@ -370,8 +372,12 @@ struct nix_cq_ctx_s { u64 qsize : 4; u64 cq_err_int : 8; u64 cq_err_int_ena : 8; +/* Ensure all context sizes are minimum 128 bytes */
Would this be better phrased as follows?
/* Ensure all context sizes are 128 bytes */
drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h struct nix_cq_ctx_s { · line 379
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h +2
-0+u64 padding[12 ]; }; +static_assert (sizeof (struct nix_cq_ctx_s ) ==NIX_MAX_CTX_SIZE );
I would suggest adding +static_assert() for all the drivers that you expect to be NIX_MAX_CTX_SIZE.
So also:
- struct nix_rq_ctx_s
- struct nix_sq_ctx_s
- struct nix_bandprof_s
Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h +1
-0+/* CN10K NIX Receive queue context structure */ struct nix_cn10k_rq_ctx_s {
Simon Horman
reviewerRe: [net-next PATCH v3 01/11] octeontx2-af: Simplify context writing and reading to hardware
Quoted 40 lines · Simon Horman
Quoted 5 lines · Subbaraya Sundeep
Simplify NIX context reading and writing by using hardware maximum context size instead of using individual sizes of each context type.
Signed-off-by Subbaraya Sundeep <[email protected]>...
Quoted 14 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h +2
-0@@ -13,6 +13,8 @@#define RVU_MULTI_BLK_VER 0x7ULL +#define NIX_MAX_CTX_SIZE 128 +/* RVU Block Address Enumeration */ enum rvu_block_addr_e {BLKADDR_RVUM =0x0ULL ,drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h struct nix_cq_ctx_s { · line 375
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h +1
-0@@ -370,8 +372,12 @@ struct nix_cq_ctx_s { u64 qsize : 4; u64 cq_err_int : 8; u64 cq_err_int_ena : 8; +/* Ensure all context sizes are minimum 128 bytes */ Would this be better phrased as follows?
/* Ensure all context sizes are 128 bytes */drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h struct nix_cq_ctx_s { · line 379
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h +2
-0+u64 padding[12 ]; }; +static_assert (sizeof (struct nix_cq_ctx_s ) ==NIX_MAX_CTX_SIZE );I would suggest adding +static_assert() for all the drivers that you expect to be
NIX_MAX_CTX_SIZE.
Quoted 4 lines
So also:
- structnix_rq_ctx_s
- structnix_sq_ctx_s
- structnix_bandprof_s
Likewise for new structures added by subsequent patches.
...
Simon Horman
reviewerRe: [net-next PATCH v3 03/11] octeontx2-af: Extend debugfs support for cn20k NIX
In reply to Subbaraya SundeepQuoted 4 lines · Subbaraya Sundeep
Extend debugfs to display CN20K NIX send, receive and completion queue contexts.
Signed-off-by Subbaraya Sundeep <[email protected]>
...
Quoted 1 line
drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.c +0
-0
...
Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.c +3
-0+void print_nix_cn20k_sq_ctx (struct seq_file *m, +struct nix_cn20k_sq_ctx_s *sq_ctx) +{
...
drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.c line 74
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.c +4
-0+seq_printf (m,"W11: octs \t\t\t%llu\n\n" , (u64 )sq_ctx->octs); +seq_printf (m,"W12: pkts \t\t\t%llu\n\n" , (u64 )sq_ctx->pkts); +seq_printf (m,"W13: aged_drop_octs \t\t\t%llu\n\n" , (u64 )sq_ctx->aged_drop_octs); +seq_printf (m,"W13: aged_drop_pkts \t\t\t%llu\n\n" , (u64 )sq_ctx->aged_drop_pkts);
nit: please line-wrap the above two lines.
Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.c +5
-0+seq_printf (m,"W14: dropped_octs \t\t%llu\n\n" , + (u64 )sq_ctx->dropped_octs); +seq_printf (m,"W15: dropped_pkts \t\t%llu\n\n" , + (u64 )sq_ctx->dropped_pkts); +}
...
Simon Horman
reviewerRe: [net-next PATCH v3 07/11] octeontx2-pf: Initialize cn20k specific aura and pool contexts
In reply to Subbaraya SundeepQuoted 9 lines · Subbaraya Sundeep
From: Linu Cherian <[email protected]>
With new CN20K NPA pool and aura contexts supported in AF driver this patch modifies PF driver to use new NPA contexts. Implement new
hw_opsfor intializing aura and pool contexts for all the silicons.Signed-off-by Linu Cherian <[email protected]>Signed-off-by Subbaraya Sundeep <[email protected]>
...
Quoted 63 lines
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c +59
-0@@ -250,3 +239,170 @@ int cn20k_register_pfvf_mbox_intr(struct otx2_nic *pf, int numvfs)return 0 ; } + +#define RQ_BP_LVL_AURA (255 - ((85 * 256) / 100))/* BP when 85% is full */ + +static int cn20k_aura_aq_init (struct otx2_nic *pfvf,int aura_id, +int pool_id,int numptrs) +{ +struct npa_cn20k_aq_enq_req *aq; +struct otx2_pool *pool; +int err; + + pool = &pfvf->qset.pool[pool_id]; + +/* Allocate memory for HW to update Aura count. +* Alloc one cache line, so that it fits all FC_STYPE modes. +*/ +if (!pool->fc_addr) { + err =qmem_alloc (pfvf->dev, &pool->fc_addr,1 ,OTX2_ALIGN ); +if (err) +return err; + } + +/* Initialize this aura's context via AF */ + aq =otx2_mbox_alloc_msg_npa_cn20k_aq_enq (&pfvf->mbox); +if (!aq) { +/* Shared mbox memory buffer is full, flush it and retry */ + err =otx2_sync_mbox_msg (&pfvf->mbox); +if (err) +return err; + aq =otx2_mbox_alloc_msg_npa_cn20k_aq_enq (&pfvf->mbox); +if (!aq) +return -ENOMEM ; + } + + aq->aura_id = aura_id; + +/* Will be filled by AF with correct pool context address */ + aq->aura.pool_addr = pool_id; + aq->aura.pool_caching =1 ; + aq->aura.shift =ilog2 (numptrs) -8 ; + aq->aura.count = numptrs; + aq->aura.limit = numptrs; + aq->aura.avg_level =255 ; + aq->aura.ena =1 ; + aq->aura.fc_ena =1 ; + aq->aura.fc_addr = pool->fc_addr->iova; + aq->aura.fc_hyst_bits =0 ;/* Store count on all updates */ + +/* Enable backpressure for RQ aura */ +if (aura_id < pfvf->hw.rqpool_cnt && !is_otx2_lbkvf (pfvf->pdev)) { + aq->aura.bp_ena =0 ; +/* If NIX1 LF is attached then specify NIX1_RX. +* +* Below NPA_AURA_S[BP_ENA] is set according to the +* NPA_BPINTF_E enumeration given as: +* 0x0 + a*0x1 where 'a' is 0 for NIX0_RX and 1 for NIX1_RX so +* NIX0_RX is 0x0 + 0*0x1 = 0 +* NIX1_RX is 0x0 + 1*0x1 = 1 +* But in HRM it is given that +* "NPA_AURA_S[BP_ENA](w1[33:32]) - Enable aura backpressure to
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c int cn20k_register_pfvf_mbox_intr(struct otx2_nic *pf, int numvfs) · line 310
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c +10
-0+* NIX-RX based on [BP] level. One bit per NIX-RX; index +* enumerated by NPA_BPINTF_E." +*/ +if (pfvf->nix_blkaddr ==BLKADDR_NIX1 ) + aq->aura.bp_ena =1 ; +#ifdef CONFIG_DCB + aq->aura.bpid = pfvf->bpid[pfvf->queue_to_pfc_map[aura_id]]; +#else + aq->aura.bpid = pfvf->bpid[0 ]; +#endif
From a build coverage point of view it is a shame that we can't use something like this here (because queue_to_pfc_map doesn't exist if CONFIG_DCB isn't enabled).
bpid_idx = IS_ENABLED(CONFIG_DCB) ? ...;
But I do wonder if somehow it's nicer to constrain the #ifdef to an as-small-as-possible helper. Something like this (compile tested only):
@@ -242,6 +242,15 @@ int cn20k_register_pfvf_mbox_intr(struct otx2_nic *pf, int numvfs)
#define RQ_BP_LVL_AURA (255 - ((85 * 256) / 100)) /* BP when 85% is full */
+static u8 cn20k_aura_bpid_idx(struct otx2_nic *pfvf, int aura_id)
+{
+#ifdef CONFIG_DCB
+ return pfvf->queue_to_pfc_map[aura_id];
+#else
+ return 0;
+#endif
+}
+
static int cn20k_aura_aq_init(struct otx2_nic *pfvf, int aura_id,
int pool_id, int numptrs)
{
@@ -289,6 +298,7 @@ static int cn20k_aura_aq_init(struct otx2_nic *pfvf, int aura_id,
/* Enable backpressure for RQ aura */
if (aura_id < pfvf->hw.rqpool_cnt && !is_otx2_lbkvf(pfvf->pdev)) {
aq->aura.bp_ena = 0;
+ u8 bpid_idx;
/* If NIX1 LF is attached then specify NIX1_RX.
*
* Below NPA_AURA_S[BP_ENA] is set according to the
@@ -303,11 +313,9 @@ static int cn20k_aura_aq_init(struct otx2_nic *pfvf, int aura_id,
*/
if (pfvf->nix_blkaddr == BLKADDR_NIX1)
aq->aura.bp_ena = 1;
-#ifdef CONFIG_DCB
- aq->aura.bpid = pfvf->bpid[pfvf->queue_to_pfc_map[aura_id]];
-#else
- aq->aura.bpid = pfvf->bpid[0];
-#endif
+
+ bpid_idx = cn20k_aura_bpid_idx(pfvf, aura_id);
+ aq->aura.bpid = pfvf->bpid[bpid_idx];
/* Set backpressure level for RQ's Aura */ aq->aura.bp = RQ_BP_LVL_AURA;
Quoted 11 lines
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c +11
-0+ +/* Set backpressure level for RQ's Aura */ + aq->aura.bp =RQ_BP_LVL_AURA ; + } + +/* Fill AQ info */ + aq->ctype =NPA_AQ_CTYPE_AURA ; + aq->op =NPA_AQ_INSTOP_INIT ; + +return 0 ; +}
...
Simon Horman
reviewerRe: [net-next PATCH v3 08/11] octeontx2-pf: Initialize new NIX SQ context for cn20k
In reply to Subbaraya SundeepQuoted 31 lines · Subbaraya Sundeep
cn20k has different NIX context for send queue hence use the new cn20k mailbox to init SQ context.
Signed-off-by Subbaraya Sundeep <[email protected]>--- .../ethernet/marvell/octeontx2/nic/cn20k.c | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c +15
-0@@ -389,11 +389,45 @@ static int cn20k_pool_aq_init(struct otx2_nic *pfvf, u16 pool_id,return 0 ; } +static int cn20k_sq_aq_init (void *dev,u16 qidx,u8 chan_offset,u16 sqb_aura) +{ +struct nix_cn20k_aq_enq_req *aq; +struct otx2_nic *pfvf = dev; + +/* Get memory to put this msg */ + aq =otx2_mbox_alloc_msg_nix_cn20k_aq_enq (&pfvf->mbox); +if (!aq) +return -ENOMEM ; + + aq->sq.cq = pfvf->hw.rx_queues + qidx; + aq->sq.max_sqe_size =NIX_MAXSQESZ_W16 ;/* 128 byte */ + aq->sq.cq_ena =1 ; + aq->sq.ena =1 ; + aq->sq.smq =otx2_get_smq_idx (pfvf, qidx);
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c static int cn20k_pool_aq_init(struct otx2_nic *pfvf, u16 pool_id, · line 416
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c +10
-0+ aq->sq.smq_rr_weight =mtu_to_dwrr_weight (pfvf, pfvf->tx_max_pktlen); + aq->sq.default_chan = pfvf->hw.tx_chan_base + chan_offset; + aq->sq.sqe_stype =NIX_STYPE_STF ;/* Cache SQB */ + aq->sq.sqb_aura = sqb_aura; + aq->sq.sq_int_ena =NIX_SQINT_BITS ; + aq->sq.qint_idx =0 ; +/* Due pipelining impact minimum 2000 unused SQ CQE's +* need to maintain to avoid CQ overflow. +*/ + aq->sq.cq_limit = ((SEND_CQ_SKID *256 ) / (pfvf->qset.sqe_cnt));
nit: Unnecessary parentheses
I think this will work just as well (completely untested):
aq->sq.cq_limit = (SEND_CQ_SKID * 256) / pfvf->qset.sqe_cnt;
Quoted 8 lines
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c +8
-0+ +/* Fill AQ info */ + aq->qidx = qidx; + aq->ctype =NIX_AQ_CTYPE_SQ ; + aq->op =NIX_AQ_INSTOP_INIT ; + +return otx2_sync_mbox_msg (&pfvf->mbox); +}
...
Simon Horman
reviewerRe: [net-next PATCH v3 09/11] octeontx2-af: Accommodate more bandwidth profiles for cn20k
In reply to Subbaraya SundeepQuoted 26 lines · Subbaraya Sundeep
CN20K has 16k of leaf profiles, 2k of middle profiles and 256 of top profiles. This patch modifies existing receive queue and bandwidth profile context structures to accommodate additional profiles of cn20k.
Signed-off-by Subbaraya Sundeep <[email protected]>--- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 13 ++++++++----- .../net/ethernet/marvell/octeontx2/af/rvu_struct.h | 6 ++++-- 2 files changed, 12 insertions(+), 7 deletions(-)drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +1
-1@@ -5856,7 +5856,7 @@ static int nix_verify_bandprof(struct nix_cn10k_aq_enq_req *req,return -EINVAL ; ipolicer = &nix_hw->ipolicer[hi_layer]; - prof_idx = req->prof.band_prof_id; + prof_idx = req->prof.band_prof_id_h <<7 | req->prof.band_prof_id;if (prof_idx >= ipolicer->band_prof.max || ipolicer->pfvf_map[prof_idx] != pcifunc)return -EINVAL ;@@ -6021,8 +6021,10 @@ static int nix_ipolicer_map_leaf_midprofs(struct rvu *rvu, aq_req->op =NIX_AQ_INSTOP_WRITE ;
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c static int nix_ipolicer_map_leaf_midprofs(struct rvu *rvu, · line 6030
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +3
-1aq_req->qidx = leaf_prof; - aq_req->prof.band_prof_id = mid_prof; + aq_req->prof.band_prof_id = mid_prof &0x7F ; aq_req->prof_mask.band_prof_id =GENMASK (6 ,0 ); + aq_req->prof.band_prof_id_h = mid_prof >>7 ; + aq_req->prof_mask.band_prof_id_h =GENMASK (3 ,0 ); aq_req->prof.hl_en =1 ; aq_req->prof_mask.hl_en =1 ;
Perhaps it follows an existing pattern in this driver. But the shifts in the above two hunks look
ripe for using FIELD_PREP/FIELD_GET along with #define GENMASK(...).
Likewise elsewhere in this patch.
...
Subbaraya Sundeep
maintainerRe: [net-next PATCH v3 01/11] octeontx2-af: Simplify context writing and reading to hardware
In reply to Simon HormanHi Simon,
Quoted 41 lines · Simon Horman
Quoted 40 lines · Simon Horman
Quoted 5 lines · Subbaraya Sundeep
Simplify NIX context reading and writing by using hardware maximum context size instead of using individual sizes of each context type.
Signed-off-by Subbaraya Sundeep <[email protected]>...
Quoted 14 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h +2
-0@@ -13,6 +13,8 @@#define RVU_MULTI_BLK_VER 0x7ULL +#define NIX_MAX_CTX_SIZE 128 +/* RVU Block Address Enumeration */ enum rvu_block_addr_e {BLKADDR_RVUM =0x0ULL ,drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h struct nix_cq_ctx_s { · line 375
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h +1
-0@@ -370,8 +372,12 @@ struct nix_cq_ctx_s { u64 qsize : 4; u64 cq_err_int : 8; u64 cq_err_int_ena : 8; +/* Ensure all context sizes are minimum 128 bytes */ Would this be better phrased as follows?
/* Ensure all context sizes are 128 bytes */drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h struct nix_cq_ctx_s { · line 379
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h +2
-0+u64 padding[12 ]; }; +static_assert (sizeof (struct nix_cq_ctx_s ) ==NIX_MAX_CTX_SIZE );I would suggest adding +static_assert() for all the drivers that you expect to be
NIX_MAX_CTX_SIZE.
Quoted 6 lines
Quoted 4 lines
So also:
- structnix_rq_ctx_s
- structnix_sq_ctx_s
- structnix_bandprof_sLikewise for new structures added by subsequent patches.
Sure. I will add for all structures
Thanks,
Sundeep
Quoted 2 lines
...
Subbaraya Sundeep
maintainerRe: [net-next PATCH v3 03/11] octeontx2-af: Extend debugfs support for cn20k NIX
In reply to Simon HormanQuoted 18 lines · Simon Horman
Quoted 4 lines · Subbaraya Sundeep
Extend debugfs to display CN20K NIX send, receive and completion queue contexts.
Signed-off-by Subbaraya Sundeep <[email protected]>...
Quoted 1 line
drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.c +0
-0...
Quoted 3 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.c +3
-0+void print_nix_cn20k_sq_ctx (struct seq_file *m, +struct nix_cn20k_sq_ctx_s *sq_ctx) +{...
Quoted 7 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.c line 74
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.c +4
-0+seq_printf (m,"W11: octs \t\t\t%llu\n\n" , (u64 )sq_ctx->octs); +seq_printf (m,"W12: pkts \t\t\t%llu\n\n" , (u64 )sq_ctx->pkts); +seq_printf (m,"W13: aged_drop_octs \t\t\t%llu\n\n" , (u64 )sq_ctx->aged_drop_octs); +seq_printf (m,"W13: aged_drop_pkts \t\t\t%llu\n\n" , (u64 )sq_ctx->aged_drop_pkts);nit: please line-wrap the above two lines.
Okay
Thanks,
Sundeep
Quoted 7 lines
Quoted 5 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.c +5
-0+seq_printf (m,"W14: dropped_octs \t\t%llu\n\n" , + (u64 )sq_ctx->dropped_octs); +seq_printf (m,"W15: dropped_pkts \t\t%llu\n\n" , + (u64 )sq_ctx->dropped_pkts); +}...
Subbaraya Sundeep
maintainerRe: [net-next PATCH v3 07/11] octeontx2-pf: Initialize cn20k specific aura and pool contexts
In reply to Simon HormanHi Simon,
Quoted 123 lines · Simon Horman
Quoted 9 lines · Subbaraya Sundeep
From: Linu Cherian <[email protected]>
With new CN20K NPA pool and aura contexts supported in AF driver this patch modifies PF driver to use new NPA contexts. Implement new
hw_opsfor intializing aura and pool contexts for all the silicons.Signed-off-by Linu Cherian <[email protected]>Signed-off-by Subbaraya Sundeep <[email protected]>...
Quoted 74 lines
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c +69
-0@@ -250,3 +239,170 @@ int cn20k_register_pfvf_mbox_intr(struct otx2_nic *pf, int numvfs)return 0 ; } + +#define RQ_BP_LVL_AURA (255 - ((85 * 256) / 100))/* BP when 85% is full */ + +static int cn20k_aura_aq_init (struct otx2_nic *pfvf,int aura_id, +int pool_id,int numptrs) +{ +struct npa_cn20k_aq_enq_req *aq; +struct otx2_pool *pool; +int err; + + pool = &pfvf->qset.pool[pool_id]; + +/* Allocate memory for HW to update Aura count. +* Alloc one cache line, so that it fits all FC_STYPE modes. +*/ +if (!pool->fc_addr) { + err =qmem_alloc (pfvf->dev, &pool->fc_addr,1 ,OTX2_ALIGN ); +if (err) +return err; + } + +/* Initialize this aura's context via AF */ + aq =otx2_mbox_alloc_msg_npa_cn20k_aq_enq (&pfvf->mbox); +if (!aq) { +/* Shared mbox memory buffer is full, flush it and retry */ + err =otx2_sync_mbox_msg (&pfvf->mbox); +if (err) +return err; + aq =otx2_mbox_alloc_msg_npa_cn20k_aq_enq (&pfvf->mbox); +if (!aq) +return -ENOMEM ; + } + + aq->aura_id = aura_id; + +/* Will be filled by AF with correct pool context address */ + aq->aura.pool_addr = pool_id; + aq->aura.pool_caching =1 ; + aq->aura.shift =ilog2 (numptrs) -8 ; + aq->aura.count = numptrs; + aq->aura.limit = numptrs; + aq->aura.avg_level =255 ; + aq->aura.ena =1 ; + aq->aura.fc_ena =1 ; + aq->aura.fc_addr = pool->fc_addr->iova; + aq->aura.fc_hyst_bits =0 ;/* Store count on all updates */ + +/* Enable backpressure for RQ aura */ +if (aura_id < pfvf->hw.rqpool_cnt && !is_otx2_lbkvf (pfvf->pdev)) { + aq->aura.bp_ena =0 ; +/* If NIX1 LF is attached then specify NIX1_RX. +* +* Below NPA_AURA_S[BP_ENA] is set according to the +* NPA_BPINTF_E enumeration given as: +* 0x0 + a*0x1 where 'a' is 0 for NIX0_RX and 1 for NIX1_RX so +* NIX0_RX is 0x0 + 0*0x1 = 0 +* NIX1_RX is 0x0 + 1*0x1 = 1 +* But in HRM it is given that +* "NPA_AURA_S[BP_ENA](w1[33:32]) - Enable aura backpressure to +* NIX-RX based on [BP] level. One bit per NIX-RX; index +* enumerated by NPA_BPINTF_E." +*/ +if (pfvf->nix_blkaddr ==BLKADDR_NIX1 ) + aq->aura.bp_ena =1 ; +#ifdef CONFIG_DCB + aq->aura.bpid = pfvf->bpid[pfvf->queue_to_pfc_map[aura_id]]; +#else + aq->aura.bpid = pfvf->bpid[0 ]; +#endif Quoted 1 line
From a build coverage point of view it is a shame that we can't use
something like this here (because
queue_to_pfc_mapdoesn't exist ifCONFIG_DCBisn't enabled).bpid_idx = IS_ENABLED(CONFIG_DCB) ? ...;But I do wonder if somehow it's nicer to constrain the #ifdef to an as-small-as-possible helper. Something like this (compile tested only):
(quoted diff) +10
-0@@ -242,6 +242,15 @@ int cn20k_register_pfvf_mbox_intr(struct otx2_nic *pf, int numvfs) #define RQ_BP_LVL_AURA (255 - ((85 * 256) / 100)) /* BP when 85% is full */ +static u8 cn20k_aura_bpid_idx(struct otx2_nic *pfvf, int aura_id) +{ +#ifdef CONFIG_DCB + return pfvf->queue_to_pfc_map[aura_id]; +#else + return 0; +#endif +} + static int cn20k_aura_aq_init(struct otx2_nic *pfvf, int aura_id, int pool_id, int numptrs) {@@ -289,6 +298,7 @@ static int cn20k_aura_aq_init(struct otx2_nic *pfvf, int aura_id, /* Enable backpressure for RQ aura */ if (aura_id < pfvf->hw.rqpool_cnt && !is_otx2_lbkvf(pfvf->pdev)) { aq->aura.bp_ena = 0; + u8 bpid_idx; /* If NIX1 LF is attached then specify NIX1_RX. * * Below NPA_AURA_S[BP_ENA] is set according to the@@ -303,11 +313,9 @@ static int cn20k_aura_aq_init(struct otx2_nic *pfvf, int aura_id, */ if (pfvf->nix_blkaddr == BLKADDR_NIX1)
Review static int cn20k_aura_aq_init(struct otx2_nic *pfvf, int aura_id, · line 319
Quoted 10 lines
(quoted diff) +3
-5aq->aura.bp_ena = 1; -#ifdef CONFIG_DCB - aq->aura.bpid = pfvf->bpid[pfvf->queue_to_pfc_map[aura_id]]; -#else - aq->aura.bpid = pfvf->bpid[0]; -#endif + + bpid_idx = cn20k_aura_bpid_idx(pfvf, aura_id); + aq->aura.bpid = pfvf->bpid[bpid_idx];
Okay will modify as per your suggestion.
Thanks,
Sundeep
Quoted 16 lines
(quoted diff) +0
-0/* Set backpressure level for RQ's Aura */ aq->aura.bp = RQ_BP_LVL_AURA;Quoted 12 lines
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c +11
-0+ +/* Set backpressure level for RQ's Aura */ + aq->aura.bp =RQ_BP_LVL_AURA ; + } + +/* Fill AQ info */ + aq->ctype =NPA_AQ_CTYPE_AURA ; + aq->op =NPA_AQ_INSTOP_INIT ; + +return 0 ; +}...
Subbaraya Sundeep
maintainerRe: [net-next PATCH v3 08/11] octeontx2-pf: Initialize new NIX SQ context for cn20k
In reply to Simon HormanQuoted 45 lines · Simon Horman
Quoted 31 lines · Subbaraya Sundeep
cn20k has different NIX context for send queue hence use the new cn20k mailbox to init SQ context.
Signed-off-by Subbaraya Sundeep <[email protected]>--- .../ethernet/marvell/octeontx2/nic/cn20k.c | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-)drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c +15
-0@@ -389,11 +389,45 @@ static int cn20k_pool_aq_init(struct otx2_nic *pfvf, u16 pool_id,return 0 ; } +static int cn20k_sq_aq_init (void *dev,u16 qidx,u8 chan_offset,u16 sqb_aura) +{ +struct nix_cn20k_aq_enq_req *aq; +struct otx2_nic *pfvf = dev; + +/* Get memory to put this msg */ + aq =otx2_mbox_alloc_msg_nix_cn20k_aq_enq (&pfvf->mbox); +if (!aq) +return -ENOMEM ; + + aq->sq.cq = pfvf->hw.rx_queues + qidx; + aq->sq.max_sqe_size =NIX_MAXSQESZ_W16 ;/* 128 byte */ + aq->sq.cq_ena =1 ; + aq->sq.ena =1 ; + aq->sq.smq =otx2_get_smq_idx (pfvf, qidx);drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c static int cn20k_pool_aq_init(struct otx2_nic *pfvf, u16 pool_id, · line 416
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c +10
-0+ aq->sq.smq_rr_weight =mtu_to_dwrr_weight (pfvf, pfvf->tx_max_pktlen); + aq->sq.default_chan = pfvf->hw.tx_chan_base + chan_offset; + aq->sq.sqe_stype =NIX_STYPE_STF ;/* Cache SQB */ + aq->sq.sqb_aura = sqb_aura; + aq->sq.sq_int_ena =NIX_SQINT_BITS ; + aq->sq.qint_idx =0 ; +/* Due pipelining impact minimum 2000 unused SQ CQE's +* need to maintain to avoid CQ overflow. +*/ + aq->sq.cq_limit = ((SEND_CQ_SKID *256 ) / (pfvf->qset.sqe_cnt));nit: Unnecessary parentheses
Quoted 3 lines
I think this will work just as well (completely untested):
aq->sq.cq_limit= (SEND_CQ_SKID* 256) /pfvf->qset.sqe_cnt;
Yes. parentheses not required. Will change it.
Thanks,
Sundeep
Quoted 11 lines
Quoted 9 lines
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c +8
-0+ +/* Fill AQ info */ + aq->qidx = qidx; + aq->ctype =NIX_AQ_CTYPE_SQ ; + aq->op =NIX_AQ_INSTOP_INIT ; + +return otx2_sync_mbox_msg (&pfvf->mbox); +}...
Subbaraya Sundeep
maintainerRe: [net-next PATCH v3 09/11] octeontx2-af: Accommodate more bandwidth profiles for cn20k
In reply to Simon HormanQuoted 42 lines · Simon Horman
Quoted 26 lines · Subbaraya Sundeep
CN20K has 16k of leaf profiles, 2k of middle profiles and 256 of top profiles. This patch modifies existing receive queue and bandwidth profile context structures to accommodate additional profiles of cn20k.
Signed-off-by Subbaraya Sundeep <[email protected]>--- drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c | 13 ++++++++----- .../net/ethernet/marvell/octeontx2/af/rvu_struct.h | 6 ++++-- 2 files changed, 12 insertions(+), 7 deletions(-)drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +1
-1@@ -5856,7 +5856,7 @@ static int nix_verify_bandprof(struct nix_cn10k_aq_enq_req *req,return -EINVAL ; ipolicer = &nix_hw->ipolicer[hi_layer]; - prof_idx = req->prof.band_prof_id; + prof_idx = req->prof.band_prof_id_h <<7 | req->prof.band_prof_id;if (prof_idx >= ipolicer->band_prof.max || ipolicer->pfvf_map[prof_idx] != pcifunc)return -EINVAL ;@@ -6021,8 +6021,10 @@ static int nix_ipolicer_map_leaf_midprofs(struct rvu *rvu, aq_req->op =NIX_AQ_INSTOP_WRITE ;drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c static int nix_ipolicer_map_leaf_midprofs(struct rvu *rvu, · line 6030
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c +3
-1aq_req->qidx = leaf_prof; - aq_req->prof.band_prof_id = mid_prof; + aq_req->prof.band_prof_id = mid_prof &0x7F ; aq_req->prof_mask.band_prof_id =GENMASK (6 ,0 ); + aq_req->prof.band_prof_id_h = mid_prof >>7 ; + aq_req->prof_mask.band_prof_id_h =GENMASK (3 ,0 ); aq_req->prof.hl_en =1 ; aq_req->prof_mask.hl_en =1 ;Perhaps it follows an existing pattern in this driver. But the shifts in the above two hunks look
ripe for using FIELD_PREP/FIELD_GET along with #define GENMASK(...).
Quoted 1 line
Likewise elsewhere in this patch.
Okay will use FIELD_* macros.
Thanks,
Sundeep
Quoted 2 lines
...