]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
octeontx2-af: Add cn20k NPA block contexts
authorLinu Cherian <lcherian@marvell.com>
Sat, 25 Oct 2025 10:32:40 +0000 (16:02 +0530)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 30 Oct 2025 09:44:08 +0000 (10:44 +0100)
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.

Signed-off-by: Linu Cherian <lcherian@marvell.com>
Signed-off-by: Subbaraya Sundeep <sbhatta@marvell.com>
Link: https://patch.msgid.link/1761388367-16579-5-git-send-email-sbhatta@marvell.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
drivers/net/ethernet/marvell/octeontx2/af/Makefile
drivers/net/ethernet/marvell/octeontx2/af/cn20k/npa.c [new file with mode: 0644]
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h
drivers/net/ethernet/marvell/octeontx2/af/mbox.h

index 57eeaa116116d4e497830b13162fc583c823890f..244de500963ed99bb19b9d694bba03a5da216701 100644 (file)
@@ -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
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npa.c b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/npa.c
new file mode 100644 (file)
index 0000000..fe8f926
--- /dev/null
@@ -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);
index ff8f0d1809c8c0c27a76a784e9c36d331eecfc1b..763f6cabd7c2476a7bc1fef854f5bc6ea6cd58c3 100644 (file)
@@ -242,4 +242,139 @@ struct nix_cn20k_rq_ctx_s {
 
 static_assert(sizeof(struct nix_cn20k_rq_ctx_s) == NIX_MAX_CTX_SIZE);
 
+struct npa_cn20k_aura_s {
+       u64 pool_addr;                  /* W0 */
+       u64 ena                   : 1;  /* W1 */
+       u64 reserved_65           : 2;
+       u64 pool_caching          : 1;
+       u64 reserved_68           : 16;
+       u64 avg_con               : 9;
+       u64 reserved_93           : 1;
+       u64 pool_drop_ena         : 1;
+       u64 aura_drop_ena         : 1;
+       u64 bp_ena                : 1;
+       u64 reserved_97_103       : 7;
+       u64 aura_drop             : 8;
+       u64 shift                 : 6;
+       u64 reserved_118_119      : 2;
+       u64 avg_level             : 8;
+       u64 count                 : 36; /* W2 */
+       u64 reserved_164_167      : 4;
+       u64 bpid                  : 12;
+       u64 reserved_180_191      : 12;
+       u64 limit                 : 36; /* W3 */
+       u64 reserved_228_231      : 4;
+       u64 bp                    : 7;
+       u64 reserved_239_243      : 5;
+       u64 fc_ena                : 1;
+       u64 fc_up_crossing        : 1;
+       u64 fc_stype              : 2;
+       u64 fc_hyst_bits          : 4;
+       u64 reserved_252_255      : 4;
+       u64 fc_addr;                    /* W4 */
+       u64 pool_drop             : 8;  /* W5 */
+       u64 update_time           : 16;
+       u64 err_int               : 8;
+       u64 err_int_ena           : 8;
+       u64 thresh_int            : 1;
+       u64 thresh_int_ena        : 1;
+       u64 thresh_up             : 1;
+       u64 reserved_363          : 1;
+       u64 thresh_qint_idx       : 7;
+       u64 reserved_371          : 1;
+       u64 err_qint_idx          : 7;
+       u64 reserved_379_383      : 5;
+       u64 thresh                : 36; /* W6*/
+       u64 rsvd_423_420          : 4;
+       u64 fc_msh_dst            : 11;
+       u64 reserved_435_438      : 4;
+       u64 op_dpc_ena            : 1;
+       u64 op_dpc_set            : 5;
+       u64 reserved_445_445      : 1;
+       u64 stream_ctx            : 1;
+       u64 unified_ctx           : 1;
+       u64 reserved_448_511;           /* W7 */
+       u64 padding[8];
+};
+
+static_assert(sizeof(struct npa_cn20k_aura_s) == NIX_MAX_CTX_SIZE);
+
+struct npa_cn20k_pool_s {
+       u64 stack_base;                 /* W0 */
+       u64 ena                   : 1;
+       u64 nat_align             : 1;
+       u64 reserved_66_67        : 2;
+       u64 stack_caching         : 1;
+       u64 reserved_69_87        : 19;
+       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;
+       uint64_t bp_0             : 7;
+       uint64_t bp_1             : 7;
+       uint64_t bp_2             : 7;
+       uint64_t bp_3             : 7;
+       uint64_t bp_4             : 7;
+       uint64_t bp_5             : 7;
+       uint64_t bp_6             : 7;
+       uint64_t bp_7             : 7;
+       uint64_t bp_ena_0         : 1;
+       uint64_t bp_ena_1         : 1;
+       uint64_t bp_ena_2         : 1;
+       uint64_t bp_ena_3         : 1;
+       uint64_t bp_ena_4         : 1;
+       uint64_t bp_ena_5         : 1;
+       uint64_t bp_ena_6         : 1;
+       uint64_t 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;                    /* W5 */
+       u64 ptr_start;                  /* W6 */
+       u64 ptr_end;                    /* W7 */
+       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 rsvd_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;
+       u64 reserved_639          : 1;
+       u64 reserved_640_703;           /* W10 */
+       u64 reserved_704_767;           /* W11 */
+       u64 reserved_768_831;           /* W12 */
+       u64 reserved_832_895;           /* W13 */
+       u64 reserved_896_959;           /* W14 */
+       u64 reserved_960_1023;          /* W15 */
+};
+
+static_assert(sizeof(struct npa_cn20k_pool_s) == NIX_MAX_CTX_SIZE);
+
 #endif
index 01086c52e78d4cef4119fd10c0dd73eef1691bc2..a3e273126e4e175abc0b60a30248e809d832bd9d 100644 (file)
@@ -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) */                               \
@@ -834,6 +836,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;