octeontx2: CN20K NPA Halo context support
Subsystems (4)
Subbaraya Sundeep
maintainerv5 cover octeontx2: CN20K NPA Halo context support
This series adds NPA Halo support for CN20K in the octeontx2 AF and PF drivers. On CN20K, NPA supports a unified "Halo" context that combines aura and pool contexts in a single structure. This is a simplification in hardware so that there is no need to initialize both Aura and Pool contexts for queues. Separate Aura and Pool contexts are needed say if we have to point many Auras to a single pool but we always use 1:1 Aura and Pool map in Octeontx2 netdev driver. Hence for CN20K use Halo context for netdevs.
The series:
1) Adds Halo context type, mbox handling, and halo_bmap tracking in AF.
2) Adds NPA DPC (diagnostic/performance counters) 32 counters with per-LF permit registers, mbox alloc/free, and teardown handling.
3) Adds debugfs for Halo (halo_ctx file and NPA context display/write for HALO ctype).
4) Switches the CN20K PF driver to use the unified Halo context and allocates a DPC counter for the NPA LF.
Changes for v5:
Fixed double free of DPC counter in error path as per AI review Modified commit message to state that backpressure
is not supported currently
Changes for v4:
Fixed DPC counter leak as per AI review
Changes for v3:
Fixed all AI reviews
Removed inline for npa_ctype_invalid(as per Simon)
Changes for v2:
Fixed all AI reviews
Removed inline and added const for npa_ctype_str(as per Simon) Fixed build warning flagged with W=1
Linu Cherian (3):
octeontx2-af: npa: cn20k: Add NPA Halo support
octeontx2-af: npa: cn20k: Add DPC support
octeontx2-af: npa: cn20k: Add debugfs for Halo
Subbaraya Sundeep (1):
octeontx2-pf: cn20k: Use unified Halo context
.../ethernet/marvell/octeontx2/af/cn20k/api.h | 6 + .../marvell/octeontx2/af/cn20k/debugfs.c | 60 +++++ .../marvell/octeontx2/af/cn20k/debugfs.h | 2 + .../ethernet/marvell/octeontx2/af/cn20k/npa.c | 156 +++++++++++++ .../ethernet/marvell/octeontx2/af/cn20k/reg.h | 7 + .../marvell/octeontx2/af/cn20k/struct.h | 81 +++++++ .../net/ethernet/marvell/octeontx2/af/mbox.h | 25 ++ .../net/ethernet/marvell/octeontx2/af/rvu.h | 5 + .../marvell/octeontx2/af/rvu_debugfs.c | 71 +++++- .../ethernet/marvell/octeontx2/af/rvu_npa.c | 77 ++++++- .../marvell/octeontx2/af/rvu_struct.h | 1 + .../ethernet/marvell/octeontx2/nic/cn20k.c | 215 +++++++++--------- .../ethernet/marvell/octeontx2/nic/cn20k.h | 3 + .../marvell/octeontx2/nic/otx2_common.h | 3 + .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 8 + 15 files changed, 601 insertions(+), 119 deletions(-)
Signature · 1 line
2.48.1
Subbaraya Sundeep
maintainerPATCH v5 1/4 octeontx2-af: npa: cn20k: Add NPA Halo support
From: Linu Cherian <[email protected]>
CN20K silicon implements unified aura and pool context type called Halo for better resource usage. Add support to handle Halo context type operations.
--- .../ethernet/marvell/octeontx2/af/cn20k/npa.c | 27 +++++++ .../marvell/octeontx2/af/cn20k/struct.h | 81 +++++++++++++++++++ .../net/ethernet/marvell/octeontx2/af/mbox.h | 6 ++ .../net/ethernet/marvell/octeontx2/af/rvu.h | 2 + .../ethernet/marvell/octeontx2/af/rvu_npa.c | 63 +++++++++++++-- .../marvell/octeontx2/af/rvu_struct.h | 1 + 6 files changed, 173 insertions(+), 7 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/cn20k/npa.c +27 -0
@@ -19,3 +19,30 @@ int rvu_mbox_handler_npa_cn20k_aq_enq(struct rvu *rvu, (struct npa_aq_enq_rsp *)rsp); }EXPORT_SYMBOL (rvu_mbox_handler_npa_cn20k_aq_enq); + +int rvu_npa_halo_hwctx_disable (struct npa_aq_enq_req *req) +{ +struct npa_cn20k_aq_enq_req *hreq; + + hreq = (struct npa_cn20k_aq_enq_req *)req; + + hreq->halo.bp_ena_0 =0 ; + hreq->halo.bp_ena_1 =0 ; + hreq->halo.bp_ena_2 =0 ; + hreq->halo.bp_ena_3 =0 ; + hreq->halo.bp_ena_4 =0 ; + hreq->halo.bp_ena_5 =0 ; + hreq->halo.bp_ena_6 =0 ; + hreq->halo.bp_ena_7 =0 ; + + hreq->halo_mask.bp_ena_0 =1 ; + hreq->halo_mask.bp_ena_1 =1 ; + hreq->halo_mask.bp_ena_2 =1 ; + hreq->halo_mask.bp_ena_3 =1 ; + hreq->halo_mask.bp_ena_4 =1 ; + hreq->halo_mask.bp_ena_5 =1 ; + hreq->halo_mask.bp_ena_6 =1 ; + hreq->halo_mask.bp_ena_7 =1 ; + +return 0 ; +}
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +81 -0
85 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +6 -0
@@ -884,6 +884,8 @@ struct npa_cn20k_aq_enq_req {struct npa_cn20k_aura_s aura;/* Valid when op == WRITE/INIT and ctype == POOL */ struct npa_cn20k_pool_s pool; +/* Valid when op == WRITE/INIT and ctype == HALO */ +struct npa_cn20k_halo_s halo; };/* Mask data when op == WRITE (1=write, 0=don't write) */ union {
@@ -891,6 +893,8 @@ struct npa_cn20k_aq_enq_req {struct npa_cn20k_aura_s aura_mask;/* Valid when op == WRITE and ctype == POOL */ struct npa_cn20k_pool_s pool_mask; +/* Valid when op == WRITE/INIT and ctype == HALO */ +struct npa_cn20k_halo_s halo_mask; }; };
@@ -901,6 +905,8 @@ struct npa_cn20k_aq_enq_rsp {struct npa_cn20k_aura_s aura;/* Valid when op == READ and ctype == POOL */ struct npa_cn20k_pool_s pool; +/* Valid when op == READ and ctype == HALO */ +struct npa_cn20k_halo_s halo; }; };
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +2 -0
@@ -261,6 +261,7 @@ struct rvu_pfvf {struct qmem *pool_ctx;struct qmem *npa_qints_ctx;unsigned long *aura_bmap; +unsigned long *halo_bmap;/* Aura and Halo are mutually exclusive */ unsigned long *pool_bmap;/* NIX contexts */
@@ -1008,6 +1009,7 @@ void rvu_npa_freemem(struct rvu *rvu);void rvu_npa_lf_teardown (struct rvu *rvu,u16 pcifunc,int npalf);int rvu_npa_aq_enq_inst (struct rvu *rvu,struct npa_aq_enq_req *req,struct npa_aq_enq_rsp *rsp); +int rvu_npa_halo_hwctx_disable (struct npa_aq_enq_req *req);/* NIX APIs */ bool is_nixlf_attached (struct rvu *rvu,u16 pcifunc);
drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c +56 -7
152 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/rvu_struct.h +1 -0
@@ -130,6 +130,7 @@ enum npa_aq_comp {enum npa_aq_ctype {NPA_AQ_CTYPE_AURA =0x0 ,NPA_AQ_CTYPE_POOL =0x1 , +NPA_AQ_CTYPE_HALO =0x2 , };/* NPA admin queue instruction opcodes */
Signature · 1 line
2.48.1
Re: [net-next PATCH v5 1/4] octeontx2-af: npa: cn20k: Add NPA Halo support
From: Subbaraya Sundeep <[email protected]>
Date: Thu, 9 Apr 2026 15:23:21 +0530
Quoted 8 lines
From: Linu Cherian <[email protected]>
CN20K silicon implements unified aura and pool context type called Halo for better resource usage. Add support to handle Halo context type operations.
Signed-off-by Linu Cherian <[email protected]>Signed-off-by Subbaraya Sundeep <[email protected]>
[...]
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h struct npa_cn20k_pool_s { · line 381
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +2
-0@@ -377,4 +377,85 @@ struct npa_cn20k_pool_s {static_assert (sizeof (struct npa_cn20k_pool_s ) ==NIX_MAX_CTX_SIZE ); +struct npa_cn20k_halo_s { +u64 stack_base :64 ;
It's redundant to add : 64 to a 64-bit field. Moreover, on 32-bit systems, the compilers sometimes complain on bitfields > 32 bits.
Quoted 68 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +68
-0+ u64 ena : 1; + u64 nat_align : 1; + u64 reserved_66_67 : 2; + u64 stack_caching : 1; + u64 reserved_69_71 : 3; + u64 aura_drop_ena : 1; + u64 reserved_73_79 : 7; + u64 aura_drop : 8; + u64 buf_offset : 12; + u64 reserved_100_103 : 4; + u64 buf_size : 12; + u64 reserved_116_119 : 4; + u64 ref_cnt_prof : 3; + u64 reserved_123_127 : 5; + u64 stack_max_pages : 32; + u64 stack_pages : 32; + u64 bp_0 : 7; + u64 bp_1 : 7; + u64 bp_2 : 7; + u64 bp_3 : 7; + u64 bp_4 : 7; + u64 bp_5 : 7; + u64 bp_6 : 7; + u64 bp_7 : 7; + u64 bp_ena_0 : 1; + u64 bp_ena_1 : 1; + u64 bp_ena_2 : 1; + u64 bp_ena_3 : 1; + u64 bp_ena_4 : 1; + u64 bp_ena_5 : 1; + u64 bp_ena_6 : 1; + u64 bp_ena_7 : 1; + u64 stack_offset : 4; + u64 reserved_260_263 : 4; + u64 shift : 6; + u64 reserved_270_271 : 2; + u64 avg_level : 8; + u64 avg_con : 9; + u64 fc_ena : 1; + u64 fc_stype : 2; + u64 fc_hyst_bits : 4; + u64 fc_up_crossing : 1; + u64 reserved_297_299 : 3; + u64 update_time : 16; + u64 reserved_316_319 : 4; + u64 fc_addr : 64; + u64 ptr_start : 64; + u64 ptr_end : 64; + u64 bpid_0 : 12; + u64 reserved_524_535 : 12; + u64 err_int : 8; + u64 err_int_ena : 8; + u64 thresh_int : 1; + u64 thresh_int_ena : 1; + u64 thresh_up : 1; + u64 reserved_555 : 1; + u64 thresh_qint_idx : 7; + u64 reserved_563 : 1; + u64 err_qint_idx : 7; + u64 reserved_571_575 : 5; + u64 thresh : 36; + u64 reserved_612_615 : 4; + u64 fc_msh_dst : 11; + u64 reserved_627_630 : 4; + u64 op_dpc_ena : 1; + u64 op_dpc_set : 5; + u64 reserved_637_637 : 1; + u64 stream_ctx : 1;
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h struct npa_cn20k_pool_s { · line 459
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +10
-0+ u64 unified_ctx : 1; + u64 reserved_640_703 : 64; + u64 reserved_704_767 : 64; + u64 reserved_768_831 : 64; + u64 reserved_832_895 : 64; + u64 reserved_896_959 : 64; + u64 reserved_960_1023 : 64; +}; + +static_assert (sizeof (struct npa_cn20k_halo_s ) ==NIX_MAX_CTX_SIZE );
Now the main question:
Is mailbox's Endianness fixed (LE/BE)? Or is it always the same as the host's ones (I doubt so)?
If not, these need to be __le{8,16,32,64} (or __be if it's Big Endian) and you need to handle the conversions manually.
Thanks,
Olek
Subbaraya Sundeep
maintainerRe: [net-next PATCH v5 1/4] octeontx2-af: npa: cn20k: Add NPA Halo support
Quoted 20 lines · Alexander Lobakin
From: Subbaraya Sundeep <[email protected]>
Date: Thu, 9 Apr 2026 15:23:21 +0530Quoted 8 lines
From: Linu Cherian <[email protected]>
CN20K silicon implements unified aura and pool context type called Halo for better resource usage. Add support to handle Halo context type operations.
Signed-off-by Linu Cherian <[email protected]>Signed-off-by Subbaraya Sundeep <[email protected]>[...]
Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +0
-0@@ -377,4 +377,85 @@ struct npa_cn20k_pool_s {
Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h struct npa_cn20k_pool_s { · line 381
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +2
-0static_assert (sizeof (struct npa_cn20k_pool_s ) ==NIX_MAX_CTX_SIZE ); +struct npa_cn20k_halo_s { +u64 stack_base :64 ;It's redundant to add : 64 to a 64-bit field.
Agreed. But this is for readability, it helps when checking HRM. For instance HRM says [703:640] and we define as u64 reserved_640_703 : 64; so that we do not have to count bits in mind.
Quoted 2 lines
Moreover, on 32-bit systems, the compilers sometimes complain on bitfields > 32 bits.
This driver depends on 64BIT.
Quoted 82 lines
Quoted 69 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +68
-0+ u64 ena : 1; + u64 nat_align : 1; + u64 reserved_66_67 : 2; + u64 stack_caching : 1; + u64 reserved_69_71 : 3; + u64 aura_drop_ena : 1; + u64 reserved_73_79 : 7; + u64 aura_drop : 8; + u64 buf_offset : 12; + u64 reserved_100_103 : 4; + u64 buf_size : 12; + u64 reserved_116_119 : 4; + u64 ref_cnt_prof : 3; + u64 reserved_123_127 : 5; + u64 stack_max_pages : 32; + u64 stack_pages : 32; + u64 bp_0 : 7; + u64 bp_1 : 7; + u64 bp_2 : 7; + u64 bp_3 : 7; + u64 bp_4 : 7; + u64 bp_5 : 7; + u64 bp_6 : 7; + u64 bp_7 : 7; + u64 bp_ena_0 : 1; + u64 bp_ena_1 : 1; + u64 bp_ena_2 : 1; + u64 bp_ena_3 : 1; + u64 bp_ena_4 : 1; + u64 bp_ena_5 : 1; + u64 bp_ena_6 : 1; + u64 bp_ena_7 : 1; + u64 stack_offset : 4; + u64 reserved_260_263 : 4; + u64 shift : 6; + u64 reserved_270_271 : 2; + u64 avg_level : 8; + u64 avg_con : 9; + u64 fc_ena : 1; + u64 fc_stype : 2; + u64 fc_hyst_bits : 4; + u64 fc_up_crossing : 1; + u64 reserved_297_299 : 3; + u64 update_time : 16; + u64 reserved_316_319 : 4; + u64 fc_addr : 64; + u64 ptr_start : 64; + u64 ptr_end : 64; + u64 bpid_0 : 12; + u64 reserved_524_535 : 12; + u64 err_int : 8; + u64 err_int_ena : 8; + u64 thresh_int : 1; + u64 thresh_int_ena : 1; + u64 thresh_up : 1; + u64 reserved_555 : 1; + u64 thresh_qint_idx : 7; + u64 reserved_563 : 1; + u64 err_qint_idx : 7; + u64 reserved_571_575 : 5; + u64 thresh : 36; + u64 reserved_612_615 : 4; + u64 fc_msh_dst : 11; + u64 reserved_627_630 : 4; + u64 op_dpc_ena : 1; + u64 op_dpc_set : 5; + u64 reserved_637_637 : 1; + u64 stream_ctx : 1;drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h struct npa_cn20k_pool_s { · line 459
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +10
-0+ u64 unified_ctx : 1; + u64 reserved_640_703 : 64; + u64 reserved_704_767 : 64; + u64 reserved_768_831 : 64; + u64 reserved_832_895 : 64; + u64 reserved_896_959 : 64; + u64 reserved_960_1023 : 64; +}; + +static_assert (sizeof (struct npa_cn20k_halo_s ) ==NIX_MAX_CTX_SIZE );Now the main question:
Quoted 5 lines
Is mailbox's Endianness fixed (LE/BE)? Or is it always the same as the host's ones (I doubt so)?
If not, these need to be __le{8,16,32,64} (or__beif it's Big Endian) and you need to handle the conversions manually.
Yes endianness is LE and fixed. This is NOT a host side driver for an endpoint card. This is driver for on chip PCI device of CN20K soc. Hope I answered your question wrt host.
Thanks,
Sundeep
Quoted 2 lines
Thanks,
Olek
Re: [net-next PATCH v5 1/4] octeontx2-af: npa: cn20k: Add NPA Halo support
From: Subbaraya Sundeep <[email protected]>
Date: Fri, 10 Apr 2026 15:05:36 +0530
Quoted 115 lines · Alexander Lobakin
Quoted 20 lines
From: Subbaraya Sundeep <[email protected]>
Date: Thu, 9 Apr 2026 15:23:21 +0530Quoted 8 lines
From: Linu Cherian <[email protected]>
CN20K silicon implements unified aura and pool context type called Halo for better resource usage. Add support to handle Halo context type operations.
Signed-off-by Linu Cherian <[email protected]>Signed-off-by Subbaraya Sundeep <[email protected]>[...]
Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +0
-0@@ -377,4 +377,85 @@ struct npa_cn20k_pool_s {Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h struct npa_cn20k_pool_s { · line 381
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +2
-0static_assert (sizeof (struct npa_cn20k_pool_s ) ==NIX_MAX_CTX_SIZE ); +struct npa_cn20k_halo_s { +u64 stack_base :64 ;It's redundant to add : 64 to a 64-bit field.
Agreed. But this is for readability, it helps when checking HRM. For instance HRM says [703:640] and we define as u64
reserved_640_703: 64; so that we do not have to count bits in mind.Quoted 2 lines
Moreover, on 32-bit systems, the compilers sometimes complain on bitfields > 32 bits.
This driver depends on 64BIT.
Quoted 82 lines
Quoted 69 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +68
-0+ u64 ena : 1; + u64 nat_align : 1; + u64 reserved_66_67 : 2; + u64 stack_caching : 1; + u64 reserved_69_71 : 3; + u64 aura_drop_ena : 1; + u64 reserved_73_79 : 7; + u64 aura_drop : 8; + u64 buf_offset : 12; + u64 reserved_100_103 : 4; + u64 buf_size : 12; + u64 reserved_116_119 : 4; + u64 ref_cnt_prof : 3; + u64 reserved_123_127 : 5; + u64 stack_max_pages : 32; + u64 stack_pages : 32; + u64 bp_0 : 7; + u64 bp_1 : 7; + u64 bp_2 : 7; + u64 bp_3 : 7; + u64 bp_4 : 7; + u64 bp_5 : 7; + u64 bp_6 : 7; + u64 bp_7 : 7; + u64 bp_ena_0 : 1; + u64 bp_ena_1 : 1; + u64 bp_ena_2 : 1; + u64 bp_ena_3 : 1; + u64 bp_ena_4 : 1; + u64 bp_ena_5 : 1; + u64 bp_ena_6 : 1; + u64 bp_ena_7 : 1; + u64 stack_offset : 4; + u64 reserved_260_263 : 4; + u64 shift : 6; + u64 reserved_270_271 : 2; + u64 avg_level : 8; + u64 avg_con : 9; + u64 fc_ena : 1; + u64 fc_stype : 2; + u64 fc_hyst_bits : 4; + u64 fc_up_crossing : 1; + u64 reserved_297_299 : 3; + u64 update_time : 16; + u64 reserved_316_319 : 4; + u64 fc_addr : 64; + u64 ptr_start : 64; + u64 ptr_end : 64; + u64 bpid_0 : 12; + u64 reserved_524_535 : 12; + u64 err_int : 8; + u64 err_int_ena : 8; + u64 thresh_int : 1; + u64 thresh_int_ena : 1; + u64 thresh_up : 1; + u64 reserved_555 : 1; + u64 thresh_qint_idx : 7; + u64 reserved_563 : 1; + u64 err_qint_idx : 7; + u64 reserved_571_575 : 5; + u64 thresh : 36; + u64 reserved_612_615 : 4; + u64 fc_msh_dst : 11; + u64 reserved_627_630 : 4; + u64 op_dpc_ena : 1; + u64 op_dpc_set : 5; + u64 reserved_637_637 : 1; + u64 stream_ctx : 1;drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h struct npa_cn20k_pool_s { · line 459
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +10
-0+ u64 unified_ctx : 1; + u64 reserved_640_703 : 64; + u64 reserved_704_767 : 64; + u64 reserved_768_831 : 64; + u64 reserved_832_895 : 64; + u64 reserved_896_959 : 64; + u64 reserved_960_1023 : 64; +}; + +static_assert (sizeof (struct npa_cn20k_halo_s ) ==NIX_MAX_CTX_SIZE );Now the main question:
Quoted 8 lines
Quoted 5 lines
Is mailbox's Endianness fixed (LE/BE)? Or is it always the same as the host's ones (I doubt so)?
If not, these need to be __le{8,16,32,64} (or__beif it's Big Endian) and you need to handle the conversions manually.Yes endianness is LE and fixed. This is NOT a host side driver for an endpoint card. This is driver for on chip PCI device of CN20K soc. Hope I answered your question wrt host.
But the mailbox is shared between the SoC and the host or HW or not? Is it possible that one client of the mailbox will have LE and the second will have BE?
Quoted 3 lines
Thanks,
Sundeep
Thanks,
Olek
Subbaraya Sundeep
maintainerRe: [net-next PATCH v5 1/4] octeontx2-af: npa: cn20k: Add NPA Halo support
Quoted 123 lines · Alexander Lobakin
From: Subbaraya Sundeep <[email protected]>
Date: Fri, 10 Apr 2026 15:05:36 +0530Quoted 120 lines · Alexander Lobakin
Quoted 20 lines
From: Subbaraya Sundeep <[email protected]>
Date: Thu, 9 Apr 2026 15:23:21 +0530Quoted 8 lines
From: Linu Cherian <[email protected]>
CN20K silicon implements unified aura and pool context type called Halo for better resource usage. Add support to handle Halo context type operations.
Signed-off-by Linu Cherian <[email protected]>Signed-off-by Subbaraya Sundeep <[email protected]>[...]
Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +0
-0@@ -377,4 +377,85 @@ struct npa_cn20k_pool_s {Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h struct npa_cn20k_pool_s { · line 381
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +2
-0static_assert (sizeof (struct npa_cn20k_pool_s ) ==NIX_MAX_CTX_SIZE ); +struct npa_cn20k_halo_s { +u64 stack_base :64 ;It's redundant to add : 64 to a 64-bit field.
Agreed. But this is for readability, it helps when checking HRM. For instance HRM says [703:640] and we define as u64
reserved_640_703: 64; so that we do not have to count bits in mind.Quoted 2 lines
Moreover, on 32-bit systems, the compilers sometimes complain on bitfields > 32 bits.
This driver depends on 64BIT.
Quoted 87 lines
Quoted 69 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +68
-0+ u64 ena : 1; + u64 nat_align : 1; + u64 reserved_66_67 : 2; + u64 stack_caching : 1; + u64 reserved_69_71 : 3; + u64 aura_drop_ena : 1; + u64 reserved_73_79 : 7; + u64 aura_drop : 8; + u64 buf_offset : 12; + u64 reserved_100_103 : 4; + u64 buf_size : 12; + u64 reserved_116_119 : 4; + u64 ref_cnt_prof : 3; + u64 reserved_123_127 : 5; + u64 stack_max_pages : 32; + u64 stack_pages : 32; + u64 bp_0 : 7; + u64 bp_1 : 7; + u64 bp_2 : 7; + u64 bp_3 : 7; + u64 bp_4 : 7; + u64 bp_5 : 7; + u64 bp_6 : 7; + u64 bp_7 : 7; + u64 bp_ena_0 : 1; + u64 bp_ena_1 : 1; + u64 bp_ena_2 : 1; + u64 bp_ena_3 : 1; + u64 bp_ena_4 : 1; + u64 bp_ena_5 : 1; + u64 bp_ena_6 : 1; + u64 bp_ena_7 : 1; + u64 stack_offset : 4; + u64 reserved_260_263 : 4; + u64 shift : 6; + u64 reserved_270_271 : 2; + u64 avg_level : 8; + u64 avg_con : 9; + u64 fc_ena : 1; + u64 fc_stype : 2; + u64 fc_hyst_bits : 4; + u64 fc_up_crossing : 1; + u64 reserved_297_299 : 3; + u64 update_time : 16; + u64 reserved_316_319 : 4; + u64 fc_addr : 64; + u64 ptr_start : 64; + u64 ptr_end : 64; + u64 bpid_0 : 12; + u64 reserved_524_535 : 12; + u64 err_int : 8; + u64 err_int_ena : 8; + u64 thresh_int : 1; + u64 thresh_int_ena : 1; + u64 thresh_up : 1; + u64 reserved_555 : 1; + u64 thresh_qint_idx : 7; + u64 reserved_563 : 1; + u64 err_qint_idx : 7; + u64 reserved_571_575 : 5; + u64 thresh : 36; + u64 reserved_612_615 : 4; + u64 fc_msh_dst : 11; + u64 reserved_627_630 : 4; + u64 op_dpc_ena : 1; + u64 op_dpc_set : 5; + u64 reserved_637_637 : 1; + u64 stream_ctx : 1;drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h struct npa_cn20k_pool_s { · line 459
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +10
-0+ u64 unified_ctx : 1; + u64 reserved_640_703 : 64; + u64 reserved_704_767 : 64; + u64 reserved_768_831 : 64; + u64 reserved_832_895 : 64; + u64 reserved_896_959 : 64; + u64 reserved_960_1023 : 64; +}; + +static_assert (sizeof (struct npa_cn20k_halo_s ) ==NIX_MAX_CTX_SIZE );Now the main question:
Is mailbox's Endianness fixed (LE/BE)? Or is it always the same as the host's ones (I doubt so)?
If not, these need to be __le{8,16,32,64} (or__beif it's Big Endian) and you need to handle the conversions manually.
Quoted 5 lines
Quoted 3 lines
Yes endianness is LE and fixed. This is NOT a host side driver for an endpoint card. This is driver for on chip PCI device of CN20K soc. Hope I answered your question wrt host.
But the mailbox is shared between the SoC and the host or HW or not? Is
In hardware it is just shared DDR region between two on chip devices and both devices access shared region using their BARs.
Quoted 2 lines
it possible that one client of the mailbox will have LE and the second will have BE?
No not possible.
Thanks,
Sundeep
Quoted 7 lines
Quoted 4 lines
Thanks,
SundeepThanks,
Olek
Re: [net-next PATCH v5 1/4] octeontx2-af: npa: cn20k: Add NPA Halo support
From: Subbaraya Sundeep <[email protected]>
Date: Fri, 10 Apr 2026 15:41:50 +0530
Quoted 128 lines · Alexander Lobakin
Quoted 127 lines
From: Subbaraya Sundeep <[email protected]>
Date: Fri, 10 Apr 2026 15:05:36 +0530Quoted 123 lines · Alexander Lobakin
Quoted 20 lines
From: Subbaraya Sundeep <[email protected]>
Date: Thu, 9 Apr 2026 15:23:21 +0530Quoted 8 lines
From: Linu Cherian <[email protected]>
CN20K silicon implements unified aura and pool context type called Halo for better resource usage. Add support to handle Halo context type operations.
Signed-off-by Linu Cherian <[email protected]>Signed-off-by Subbaraya Sundeep <[email protected]>[...]
Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +0
-0@@ -377,4 +377,85 @@ struct npa_cn20k_pool_s {Quoted 6 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h struct npa_cn20k_pool_s { · line 381
Quoted 4 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +2
-0static_assert (sizeof (struct npa_cn20k_pool_s ) ==NIX_MAX_CTX_SIZE ); +struct npa_cn20k_halo_s { +u64 stack_base :64 ;It's redundant to add : 64 to a 64-bit field.
Agreed. But this is for readability, it helps when checking HRM. For instance HRM says [703:640] and we define as u64
reserved_640_703: 64; so that we do not have to count bits in mind.Quoted 2 lines
Moreover, on 32-bit systems, the compilers sometimes complain on bitfields > 32 bits.
This driver depends on 64BIT.
Quoted 82 lines
Quoted 69 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +68
-0+ u64 ena : 1; + u64 nat_align : 1; + u64 reserved_66_67 : 2; + u64 stack_caching : 1; + u64 reserved_69_71 : 3; + u64 aura_drop_ena : 1; + u64 reserved_73_79 : 7; + u64 aura_drop : 8; + u64 buf_offset : 12; + u64 reserved_100_103 : 4; + u64 buf_size : 12; + u64 reserved_116_119 : 4; + u64 ref_cnt_prof : 3; + u64 reserved_123_127 : 5; + u64 stack_max_pages : 32; + u64 stack_pages : 32; + u64 bp_0 : 7; + u64 bp_1 : 7; + u64 bp_2 : 7; + u64 bp_3 : 7; + u64 bp_4 : 7; + u64 bp_5 : 7; + u64 bp_6 : 7; + u64 bp_7 : 7; + u64 bp_ena_0 : 1; + u64 bp_ena_1 : 1; + u64 bp_ena_2 : 1; + u64 bp_ena_3 : 1; + u64 bp_ena_4 : 1; + u64 bp_ena_5 : 1; + u64 bp_ena_6 : 1; + u64 bp_ena_7 : 1; + u64 stack_offset : 4; + u64 reserved_260_263 : 4; + u64 shift : 6; + u64 reserved_270_271 : 2; + u64 avg_level : 8; + u64 avg_con : 9; + u64 fc_ena : 1; + u64 fc_stype : 2; + u64 fc_hyst_bits : 4; + u64 fc_up_crossing : 1; + u64 reserved_297_299 : 3; + u64 update_time : 16; + u64 reserved_316_319 : 4; + u64 fc_addr : 64; + u64 ptr_start : 64; + u64 ptr_end : 64; + u64 bpid_0 : 12; + u64 reserved_524_535 : 12; + u64 err_int : 8; + u64 err_int_ena : 8; + u64 thresh_int : 1; + u64 thresh_int_ena : 1; + u64 thresh_up : 1; + u64 reserved_555 : 1; + u64 thresh_qint_idx : 7; + u64 reserved_563 : 1; + u64 err_qint_idx : 7; + u64 reserved_571_575 : 5; + u64 thresh : 36; + u64 reserved_612_615 : 4; + u64 fc_msh_dst : 11; + u64 reserved_627_630 : 4; + u64 op_dpc_ena : 1; + u64 op_dpc_set : 5; + u64 reserved_637_637 : 1; + u64 stream_ctx : 1;drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h struct npa_cn20k_pool_s { · line 459
Quoted 10 lines
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h +10
-0+ u64 unified_ctx : 1; + u64 reserved_640_703 : 64; + u64 reserved_704_767 : 64; + u64 reserved_768_831 : 64; + u64 reserved_832_895 : 64; + u64 reserved_896_959 : 64; + u64 reserved_960_1023 : 64; +}; + +static_assert (sizeof (struct npa_cn20k_halo_s ) ==NIX_MAX_CTX_SIZE );Now the main question:
Quoted 5 lines
Is mailbox's Endianness fixed (LE/BE)? Or is it always the same as the host's ones (I doubt so)?
If not, these need to be __le{8,16,32,64} (or__beif it's Big Endian) and you need to handle the conversions manually.Yes endianness is LE and fixed. This is NOT a host side driver for an endpoint card. This is driver for on chip PCI device of CN20K soc. Hope I answered your question wrt host.
Quoted 6 lines
Quoted 1 line
But the mailbox is shared between the SoC and the host or HW or not? Is
In hardware it is just shared DDR region between two on chip devices and both devices access shared region using their BARs.
Quoted 2 lines
it possible that one client of the mailbox will have LE and the second will have BE?
No not possible.
Okay, so seems like it's safe to use Endianness-agnostic types without messing with __le/__be, thanks for explaining.
Thanks,
Olek
Subbaraya Sundeep
maintainerPATCH v5 2/4 octeontx2-af: npa: cn20k: Add DPC support
In reply to Subbaraya SundeepFrom: Linu Cherian <[email protected]>
CN20k introduces 32 diagnostic and performance counters that are shared across all NPA LFs.
Counters being shared, each PF driver need to request for a counter with the required configuration to the AF, so that a counter can be allocated and mapped to the respective LF with the requested configuration.
Add new mbox messages, npa_dpc_alloc/free to handle this.
Also ensure all the LF to DPC counter mappings are cleared at the time of LF free/teardown.
--- .../ethernet/marvell/octeontx2/af/cn20k/api.h | 6 + .../ethernet/marvell/octeontx2/af/cn20k/npa.c | 129 ++++++++++++++++++ .../ethernet/marvell/octeontx2/af/cn20k/reg.h | 7 + .../net/ethernet/marvell/octeontx2/af/mbox.h | 19 +++ .../net/ethernet/marvell/octeontx2/af/rvu.h | 3 + .../ethernet/marvell/octeontx2/af/rvu_npa.c | 14 +- 6 files changed, 177 insertions(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/af/cn20k/api.h +6 -0
@@ -29,4 +29,10 @@ int cn20k_mbox_setup(struct otx2_mbox *mbox, struct pci_dev *pdev, void *reg_base, int direction, int ndevs);void cn20k_rvu_enable_afvf_intr (struct rvu *rvu,int vfs);void cn20k_rvu_disable_afvf_intr (struct rvu *rvu,int vfs); + +int npa_cn20k_dpc_alloc (struct rvu *rvu,struct npa_cn20k_dpc_alloc_req *req, +struct npa_cn20k_dpc_alloc_rsp *rsp); +int npa_cn20k_dpc_free (struct rvu *rvu,struct npa_cn20k_dpc_free_req *req); +void npa_cn20k_dpc_free_all (struct rvu *rvu,u16 pcifunc); +#endif /* CN20K_API_H */
drivers/net/ethernet/marvell/octeontx2/af/cn20k/npa.c +129 -0
138 lines not on this page · raw message
drivers/net/ethernet/marvell/octeontx2/af/cn20k/reg.h +7 -0
@@ -143,4 +143,11 @@ offset = (0xb000000ull | (a) <<4 | (b) <<20 ); \ offset; }) +/* NPA Registers */ +#define NPA_AF_DPCX_CFG (a) (0x800 | (a) << 6) +#define NPA_AF_DPC_PERMITX (a) (0x1000 | (a) << 3) + +#define NPA_DPC_MAX 32 +#define NPA_DPC_LFS_PER_REG 64 +#endif /* RVU_MBOX_REG_H */
drivers/net/ethernet/marvell/octeontx2/af/mbox.h +19 -0
@@ -213,6 +213,10 @@ 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) \ +M (NPA_CN20K_DPC_ALLOC ,0x405 , npa_cn20k_dpc_alloc, npa_cn20k_dpc_alloc_req, \ + npa_cn20k_dpc_alloc_rsp) \ +M (NPA_CN20K_DPC_FREE ,0x406 , npa_cn20k_dpc_free, npa_cn20k_dpc_free_req, \ + msg_rsp) \/* SSO/SSOW mbox IDs (range 0x600 - 0x7FF) */ \/* TIM mbox IDs (range 0x800 - 0x9FF) */ \/* CPT mbox IDs (range 0xA00 - 0xBFF) */ \
@@ -910,6 +914,21 @@ struct npa_cn20k_aq_enq_rsp { }; }; +struct npa_cn20k_dpc_alloc_req { +struct mbox_msghdr hdr; +u16 dpc_conf; +}; + +struct npa_cn20k_dpc_alloc_rsp { +struct mbox_msghdr hdr; +u8 cntr_id; +}; + +struct npa_cn20k_dpc_free_req { +struct mbox_msghdr hdr; +u8 cntr_id; +}; +/* Disable all contexts of type 'ctype' */ struct hwctx_disable_req {struct mbox_msghdr hdr;
drivers/net/ethernet/marvell/octeontx2/af/rvu.h +3 -0
@@ -663,6 +663,9 @@ struct rvu {/* CPT interrupt lock */ spinlock_t cpt_intr_lock; +/* NPA */ +struct rsrc_bmap npa_dpc; +struct mutex mbox_lock;/* Serialize mbox up and down msgs */ u16 rep_pcifunc;bool altaf_ready;
drivers/net/ethernet/marvell/octeontx2/af/rvu_npa.c +13 -1
@@ -8,6 +8,8 @@#include <linux/module.h> #include <linux/pci.h> +#include "cn20k/api.h" +#include "cn20k/reg.h" #include "rvu_struct.h" #include "rvu_reg.h" #include "rvu.h"
@@ -504,6 +506,8 @@ int rvu_mbox_handler_npa_lf_free(struct rvu *rvu, struct msg_req *req,return NPA_AF_ERR_LF_RESET ; } +if (is_cn20k (rvu->pdev)) +npa_cn20k_dpc_free_all (rvu, pcifunc);npa_ctx_free (rvu, pfvf);return 0 ;
@@ -569,12 +573,17 @@ static int npa_aq_init(struct rvu *rvu, struct rvu_block *block)int rvu_npa_init (struct rvu *rvu) {struct rvu_hwinfo *hw = rvu->hw; -int blkaddr; +int err, blkaddr; blkaddr =rvu_get_blkaddr (rvu,BLKTYPE_NPA ,0 );if (blkaddr <0 )return 0 ; + rvu->npa_dpc.max =NPA_DPC_MAX ; + err =rvu_alloc_bitmap (&rvu->npa_dpc); +if (err) +return err; +/* Initialize admin queue */ return npa_aq_init (rvu, &hw->block[blkaddr]); }
@@ -591,6 +600,7 @@ void rvu_npa_freemem(struct rvu *rvu) block = &hw->block[blkaddr];rvu_aq_free (rvu, block->aq); +kfree (rvu->npa_dpc.bmap); }void rvu_npa_lf_teardown (struct rvu *rvu,u16 pcifunc,int npalf)
@@ -611,6 +621,8 @@ void rvu_npa_lf_teardown(struct rvu *rvu, u16 pcifunc, int npalf) ctx_req.ctype =NPA_AQ_CTYPE_HALO ;npa_lf_hwctx_disable (rvu, &ctx_req); +if (is_cn20k (rvu->pdev)) +npa_cn20k_dpc_free_all (rvu, pcifunc);npa_ctx_free (rvu, pfvf); }
Signature · 1 line
2.48.1
Subbaraya Sundeep
maintainerPATCH v5 3/4 octeontx2-af: npa: cn20k: Add debugfs for Halo
In reply to Subbaraya SundeepFrom: Linu Cherian <[email protected]>
Similar to other hardware contexts add debugfs support for unified Halo context.
Sample output on cn20k::/sys/kernel/debug/cn20k/npa # cat halo_ctx
======halo : 2=======
W0: Stack base ffffff790000
W1: ena 1
W1: nat_align 0
W1: stack_caching 1
W1: aura drop ena 0
W1: aura drop 0
W1: buf_offset 0
W1: buf_size 32
W1: ref_cnt_prof 0
W2: stack_max_pages 13
W2: stack_pages 11
W3: bp_0 0
W3: bp_1 0
W3: bp_2 0
snip ..
--- .../marvell/octeontx2/af/cn20k/debugfs.c | 60 ++++++++++++++++ .../marvell/octeontx2/af/cn20k/debugfs.h | 2 + .../marvell/octeontx2/af/rvu_debugfs.c | 71 ++++++++++++++++--- 3 files changed, 125 insertions(+), 8 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.c +60 -0
@@ -489,3 +489,63 @@ void print_npa_cn20k_pool_ctx(struct seq_file *m, pool->thresh_qint_idx, pool->err_qint_idx);seq_printf (m,"W8: fc_msh_dst\t\t%d\n" , pool->fc_msh_dst); } + +void print_npa_cn20k_halo_ctx (struct seq_file *m,struct npa_aq_enq_rsp *rsp) +{ +struct npa_cn20k_aq_enq_rsp *cn20k_rsp; +struct npa_cn20k_halo_s *halo; + + cn20k_rsp = (struct npa_cn20k_aq_enq_rsp *)rsp; + halo = &cn20k_rsp->halo; + +seq_printf (m,"W0: Stack base\t\t%llx\n" , halo->stack_base); + +seq_printf (m,"W1: ena \t\t%d\nW1: nat_align \t\t%d\n" , + halo->ena, halo->nat_align); +seq_printf (m,"W1: stack_caching\t%d\n" , + halo->stack_caching); +seq_printf (m,"W1: aura drop ena\t%d\n" , halo->aura_drop_ena); +seq_printf (m,"W1: aura drop\t\t%d\n" , halo->aura_drop); +seq_printf (m,"W1: buf_offset\t\t%d\nW1: buf_size\t\t%d\n" , + halo->buf_offset, halo->buf_size); +seq_printf (m,"W1: ref_cnt_prof\t\t%d\n" , halo->ref_cnt_prof); +seq_printf (m,"W2: stack_max_pages \t%d\nW2: stack_pages\t\t%d\n" , + halo->stack_max_pages, halo->stack_pages); +seq_printf (m,"W3: bp_0\t\t%d\nW3: bp_1\t\t%d\nW3: bp_2\t\t%d\n" , + halo->bp_0, halo->bp_1, halo->bp_2); +seq_printf (m,"W3: bp_3\t\t%d\nW3: bp_4\t\t%d\nW3: bp_5\t\t%d\n" , + halo->bp_3, halo->bp_4, halo->bp_5); +seq_printf (m,"W3: bp_6\t\t%d\nW3: bp_7\t\t%d\nW3: bp_ena_0\t\t%d\n" , + halo->bp_6, halo->bp_7, halo->bp_ena_0); +seq_printf (m,"W3: bp_ena_1\t\t%d\nW3: bp_ena_2\t\t%d\n" , + halo->bp_ena_1, halo->bp_ena_2); +seq_printf (m,"W3: bp_ena_3\t\t%d\nW3: bp_ena_4\t\t%d\n" , + halo->bp_ena_3, halo->bp_ena_4); +seq_printf (m,"W3: bp_ena_5\t\t%d\nW3: bp_ena_6\t\t%d\n" , + halo->bp_ena_5, halo->bp_ena_6); +seq_printf (m,"W3: bp_ena_7\t\t%d\n" , halo->bp_ena_7); +seq_printf (m,"W4: stack_offset\t%d\nW4: shift\t\t%d\nW4: avg_level\t\t%d\n" , + halo->stack_offset, halo->shift, halo->avg_level); +seq_printf (m,"W4: avg_con \t\t%d\nW4: fc_ena\t\t%d\nW4: fc_stype\t\t%d\n" , + halo->avg_con, halo->fc_ena, halo->fc_stype); +seq_printf (m,"W4: fc_hyst_bits\t%d\nW4: fc_up_crossing\t%d\n" , + halo->fc_hyst_bits, halo->fc_up_crossing); +seq_printf (m,"W4: update_time\t\t%d\n" , halo->update_time); +seq_printf (m,"W5: fc_addr\t\t%llx\n" , halo->fc_addr); +seq_printf (m,"W6: ptr_start\t\t%llx\n" , halo->ptr_start); +seq_printf (m,"W7: ptr_end\t\t%llx\n" , halo->ptr_end); +seq_printf (m,"W8: bpid_0\t\t%d\n" , halo->bpid_0); +seq_printf (m,"W8: err_int \t\t%d\nW8: err_int_ena\t\t%d\n" , + halo->err_int, halo->err_int_ena); +seq_printf (m,"W8: thresh_int\t\t%d\nW8: thresh_int_ena \t%d\n" , + halo->thresh_int, halo->thresh_int_ena); +seq_printf (m,"W8: thresh_up\t\t%d\nW8: thresh_qint_idx\t%d\n" , + halo->thresh_up, halo->thresh_qint_idx); +seq_printf (m,"W8: err_qint_idx \t%d\n" , halo->err_qint_idx); +seq_printf (m,"W9: thresh\t\t%llu\n" , (u64 )halo->thresh); +seq_printf (m,"W9: fc_msh_dst\t\t%d\n" , halo->fc_msh_dst); +seq_printf (m,"W9: op_dpc_ena\t\t%d\nW9: op_dpc_set\t\t%d\n" , + halo->op_dpc_ena, halo->op_dpc_set); +seq_printf (m,"W9: stream_ctx\t\t%d\nW9: unified_ctx\t\t%d\n" , + halo->stream_ctx, halo->unified_ctx); +}
drivers/net/ethernet/marvell/octeontx2/af/cn20k/debugfs.h +2 -0
@@ -27,5 +27,7 @@ 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); +void print_npa_cn20k_halo_ctx (struct seq_file *m, +struct npa_aq_enq_rsp *rsp);#endif
drivers/net/ethernet/marvell/octeontx2/af/rvu_debugfs.c +63 -8
156 lines not on this page · raw message
Signature · 1 line
2.48.1
Subbaraya Sundeep
maintainerPATCH v5 4/4 octeontx2-pf: cn20k: Use unified Halo context
In reply to Subbaraya SundeepUse unified Halo context present in CN20K hardware for octeontx2 netdevs instead of aura and pool contexts. Note that with this halo context in place RQ backpressure is not being configured and the same will be supported later.
--- .../ethernet/marvell/octeontx2/nic/cn20k.c | 215 +++++++++--------- .../ethernet/marvell/octeontx2/nic/cn20k.h | 3 + .../marvell/octeontx2/nic/otx2_common.h | 3 + .../ethernet/marvell/octeontx2/nic/otx2_pf.c | 8 + 4 files changed, 126 insertions(+), 103 deletions(-)
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.c +112 -103
@@ -242,15 +242,6 @@ 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_tc_get_entry_index (struct otx2_flow_config *flow_cfg,struct otx2_tc_flow *node) {
@@ -517,84 +508,7 @@ int cn20k_tc_alloc_entry(struct otx2_nic *nic,return 0 ; } -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; -u8 bpid_idx; -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 ; - - 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 ; - } - -/* Fill AQ info */ - aq->ctype =NPA_AQ_CTYPE_AURA ; - aq->op =NPA_AQ_INSTOP_INIT ; - -return 0 ; -} - -static int cn20k_pool_aq_init (struct otx2_nic *pfvf,u16 pool_id, +static int cn20k_halo_aq_init (struct otx2_nic *pfvf,u16 pool_id,int stack_pages,int numptrs,int buf_size,int type) {
@@ -610,36 +524,57 @@ static int cn20k_pool_aq_init(struct otx2_nic *pfvf, u16 pool_id,if (err)return err; +/* 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) { +qmem_free (pfvf->dev, pool->stack); +return err; + } + } + pool->rbsize = buf_size; -/* Initialize this pool's context via AF */ +/* 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) { -qmem_free (pfvf->dev, pool->stack); -return err; - } +if (err) + goto free_mem; aq =otx2_mbox_alloc_msg_npa_cn20k_aq_enq (&pfvf->mbox);if (!aq) { -qmem_free (pfvf->dev, pool->stack); -return -ENOMEM ; + err = -ENOMEM ; + goto free_mem; } } aq->aura_id = pool_id; - aq->pool.stack_base = pool->stack->iova; - aq->pool.stack_caching =1 ; - aq->pool.ena =1 ; - aq->pool.buf_size = buf_size /128 ; - aq->pool.stack_max_pages = stack_pages; - aq->pool.shift =ilog2 (numptrs) -8 ; - aq->pool.ptr_start =0 ; - aq->pool.ptr_end = ~0ULL ; + + aq->halo.stack_base = pool->stack->iova; + aq->halo.stack_caching =1 ; + aq->halo.ena =1 ; + aq->halo.buf_size = buf_size /128 ; + aq->halo.stack_max_pages = stack_pages; + aq->halo.shift =ilog2 (numptrs) -8 ; + aq->halo.ptr_start =0 ; + aq->halo.ptr_end = ~0ULL ; + + aq->halo.avg_level =255 ; + aq->halo.fc_ena =1 ; + aq->halo.fc_addr = pool->fc_addr->iova; + aq->halo.fc_hyst_bits =0 ;/* Store count on all updates */ + +if (pfvf->npa_dpc_valid) { + aq->halo.op_dpc_ena =1 ; + aq->halo.op_dpc_set = pfvf->npa_dpc; + } + aq->halo.unified_ctx =1 ;/* Fill AQ info */ - aq->ctype =NPA_AQ_CTYPE_POOL ; + aq->ctype =NPA_AQ_CTYPE_HALO ; aq->op =NPA_AQ_INSTOP_INIT ;if (type !=AURA_NIX_RQ ) {
@@ -661,6 +596,80 @@ static int cn20k_pool_aq_init(struct otx2_nic *pfvf, u16 pool_id, }return 0 ; + +free_mem: +qmem_free (pfvf->dev, pool->stack); +qmem_free (pfvf->dev, pool->fc_addr); +return err; +} + +static int cn20k_aura_aq_init (struct otx2_nic *pfvf,int aura_id, +int pool_id,int numptrs) +{ +return 0 ; +} + +static int cn20k_pool_aq_init (struct otx2_nic *pfvf,u16 pool_id, +int stack_pages,int numptrs,int buf_size, +int type) +{ +return cn20k_halo_aq_init (pfvf, pool_id, stack_pages, + numptrs, buf_size, type); +} + +int cn20k_npa_alloc_dpc (struct otx2_nic *nic) +{ +struct npa_cn20k_dpc_alloc_req *req; +struct npa_cn20k_dpc_alloc_rsp *rsp; +int err; + + req =otx2_mbox_alloc_msg_npa_cn20k_dpc_alloc (&nic->mbox); +if (!req) +return -ENOMEM ; + +/* Count successful ALLOC requests only */ + req->dpc_conf =1ULL <<4 ; + + err =otx2_sync_mbox_msg (&nic->mbox); +if (err) +return err; + + rsp = (struct npa_cn20k_dpc_alloc_rsp *)otx2_mbox_get_rsp (&nic->mbox.mbox, +0 , &req->hdr); +if (IS_ERR (rsp)) +return PTR_ERR (rsp); + + nic->npa_dpc = rsp->cntr_id; + nic->npa_dpc_valid = true; + +return 0 ; +} + +int cn20k_npa_free_dpc (struct otx2_nic *nic) +{ +struct npa_cn20k_dpc_free_req *req; +int err; + +if (!nic->npa_dpc_valid) +return 0 ; + +mutex_lock (&nic->mbox.lock); + + req =otx2_mbox_alloc_msg_npa_cn20k_dpc_free (&nic->mbox); +if (!req) { +mutex_unlock (&nic->mbox.lock); +return -ENOMEM ; + } + + req->cntr_id = nic->npa_dpc; + + err =otx2_sync_mbox_msg (&nic->mbox); + + nic->npa_dpc_valid = false; + +mutex_unlock (&nic->mbox.lock); + +return err; }static int cn20k_sq_aq_init (void *dev,u16 qidx,u8 chan_offset,u16 sqb_aura)
drivers/net/ethernet/marvell/octeontx2/nic/cn20k.h +3 -0
@@ -28,4 +28,7 @@ int cn20k_tc_alloc_entry(struct otx2_nic *nic,struct otx2_tc_flow *new_node, struct npc_install_flow_req *dummy);int cn20k_tc_free_mcam_entry (struct otx2_nic *nic,u16 entry); +int cn20k_npa_alloc_dpc (struct otx2_nic *nic); +int cn20k_npa_free_dpc (struct otx2_nic *nic); +#endif /* CN20K_H */
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h +3 -0
@@ -592,6 +592,9 @@ struct otx2_nic {struct cn10k_ipsec ipsec;/* af_xdp zero-copy */ unsigned long *af_xdp_zc_qidx; + +bool npa_dpc_valid; +u8 npa_dpc;/* NPA DPC counter id */ };static inline bool is_otx2_lbkvf (struct pci_dev *pdev)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_pf.c +8 -0
@@ -1651,6 +1651,9 @@ int otx2_init_hw_resources(struct otx2_nic *pf)if (!is_otx2_lbkvf (pf->pdev))otx2_nix_config_bp (pf, true); +if (is_cn20k (pf->pdev)) +cn20k_npa_alloc_dpc (pf); +/* Init Auras and pools used by NIX RQ, for free buffer ptrs */ err =otx2_rq_aura_pool_init (pf);if (err) {
@@ -1726,6 +1729,8 @@ int otx2_init_hw_resources(struct otx2_nic *pf)otx2_ctx_disable (mbox,NPA_AQ_CTYPE_AURA , true);otx2_aura_pool_free (pf); err_free_nix_lf: +if (pf->npa_dpc_valid) +cn20k_npa_free_dpc (pf);mutex_lock (&mbox->lock); free_req =otx2_mbox_alloc_msg_nix_lf_free (mbox);if (free_req) {
@@ -1790,6 +1795,9 @@ void otx2_free_hw_resources(struct otx2_nic *pf)otx2_free_sq_res (pf); +if (is_cn20k (pf->pdev)) +cn20k_npa_free_dpc (pf); +/* Free RQ buffer pointers*/ otx2_free_aura_ptr (pf,AURA_NIX_RQ );
Signature · 1 line
2.48.1