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

Signed-off-by: Subbaraya Sundeep <sbhatta@marvell.com>
Link: https://patch.msgid.link/1761388367-16579-3-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/nix.c [new file with mode: 0644]
drivers/net/ethernet/marvell/octeontx2/af/cn20k/struct.h
drivers/net/ethernet/marvell/octeontx2/af/mbox.h
drivers/net/ethernet/marvell/octeontx2/af/rvu.h
drivers/net/ethernet/marvell/octeontx2/af/rvu_nix.c

index 532813d8d02817b1e20af41058b9f158d3b760ec..cb77b978eda588eb2ee70d98192118a253760de9 100644 (file)
@@ -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
diff --git a/drivers/net/ethernet/marvell/octeontx2/af/cn20k/nix.c b/drivers/net/ethernet/marvell/octeontx2/af/cn20k/nix.c
new file mode 100644 (file)
index 0000000..aa2016f
--- /dev/null
@@ -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);
+}
index 76ce3ec6da9cdb5b7d77fd2374a6606b12844be0..ff8f0d1809c8c0c27a76a784e9c36d331eecfc1b 100644 (file)
@@ -8,6 +8,8 @@
 #ifndef STRUCT_H
 #define STRUCT_H
 
+#define NIX_MAX_CTX_SIZE               128
+
 /*
  * CN20k RVU PF MBOX Interrupt Vector Enumeration
  *
@@ -37,4 +39,207 @@ enum rvu_af_cn20k_int_vec_e {
        RVU_AF_CN20K_INT_VEC_PFAF1_MBOX1        = 0x9,
        RVU_AF_CN20K_INT_VEC_CNT                = 0xa,
 };
+
+struct nix_cn20k_sq_ctx_s {
+       u64 ena                         :  1; /* W0 */
+       u64 qint_idx                    :  6;
+       u64 substream                   : 20;
+       u64 sdp_mcast                   :  1;
+       u64 cq                          : 20;
+       u64 sqe_way_mask                : 16;
+       u64 smq                         : 11; /* W1 */
+       u64 cq_ena                      :  1;
+       u64 xoff                        :  1;
+       u64 sso_ena                     :  1;
+       u64 smq_rr_weight               : 14;
+       u64 default_chan                : 12;
+       u64 sqb_count                   : 16;
+       u64 reserved_120_120            :  1;
+       u64 smq_rr_count_lb             :  7;
+       u64 smq_rr_count_ub             : 25; /* W2 */
+       u64 sqb_aura                    : 20;
+       u64 sq_int                      :  8;
+       u64 sq_int_ena                  :  8;
+       u64 sqe_stype                   :  2;
+       u64 reserved_191_191            :  1;
+       u64 max_sqe_size                :  2; /* W3 */
+       u64 cq_limit                    :  8;
+       u64 lmt_dis                     :  1;
+       u64 mnq_dis                     :  1;
+       u64 smq_next_sq                 : 20;
+       u64 smq_lso_segnum              :  8;
+       u64 tail_offset                 :  6;
+       u64 smenq_offset                :  6;
+       u64 head_offset                 :  6;
+       u64 smenq_next_sqb_vld          :  1;
+       u64 smq_pend                    :  1;
+       u64 smq_next_sq_vld             :  1;
+       u64 reserved_253_255            :  3;
+       u64 next_sqb                    : 64; /* W4 */
+       u64 tail_sqb                    : 64; /* W5 */
+       u64 smenq_sqb                   : 64; /* W6 */
+       u64 smenq_next_sqb              : 64; /* W7 */
+       u64 head_sqb                    : 64; /* W8 */
+       u64 reserved_576_583            :  8; /* W9 */
+       u64 vfi_lso_total               : 18;
+       u64 vfi_lso_sizem1              :  3;
+       u64 vfi_lso_sb                  :  8;
+       u64 vfi_lso_mps                 : 14;
+       u64 vfi_lso_vlan0_ins_ena       :  1;
+       u64 vfi_lso_vlan1_ins_ena       :  1;
+       u64 vfi_lso_vld                 :  1;
+       u64 reserved_630_639            : 10;
+       u64 scm_lso_rem                 : 18; /* W10 */
+       u64 reserved_658_703            : 46;
+       u64 octs                        : 48; /* W11 */
+       u64 reserved_752_767            : 16;
+       u64 pkts                        : 48; /* W12 */
+       u64 reserved_816_831            : 16;
+       u64 aged_drop_octs              : 32; /* W13 */
+       u64 aged_drop_pkts              : 32;
+       u64 dropped_octs                : 48; /* W14 */
+       u64 reserved_944_959            : 16;
+       u64 dropped_pkts                : 48; /* W15 */
+       u64 reserved_1008_1023          : 16;
+};
+
+static_assert(sizeof(struct nix_cn20k_sq_ctx_s) == NIX_MAX_CTX_SIZE);
+
+struct nix_cn20k_cq_ctx_s {
+       u64 base                        : 64; /* W0 */
+       u64 lbp_ena                     :  1; /* W1 */
+       u64 lbpid_low                   :  3;
+       u64 bp_ena                      :  1;
+       u64 lbpid_med                   :  3;
+       u64 bpid                        :  9;
+       u64 lbpid_high                  :  3;
+       u64 qint_idx                    :  7;
+       u64 cq_err                      :  1;
+       u64 cint_idx                    :  7;
+       u64 avg_con                     :  9;
+       u64 wrptr                       : 20;
+       u64 tail                        : 20; /* W2 */
+       u64 head                        : 20;
+       u64 avg_level                   :  8;
+       u64 update_time                 : 16;
+       u64 bp                          :  8; /* W3 */
+       u64 drop                        :  8;
+       u64 drop_ena                    :  1;
+       u64 ena                         :  1;
+       u64 cpt_drop_err_en             :  1;
+       u64 reserved_211_211            :  1;
+       u64 msh_dst                     : 11;
+       u64 msh_valid                   :  1;
+       u64 stash_thresh                :  4;
+       u64 lbp_frac                    :  4;
+       u64 caching                     :  1;
+       u64 stashing                    :  1;
+       u64 reserved_234_235            :  2;
+       u64 qsize                       :  4;
+       u64 cq_err_int                  :  8;
+       u64 cq_err_int_ena              :  8;
+       u64 bpid_ext                    :  2; /* W4 */
+       u64 reserved_258_259            :  2;
+       u64 lbpid_ext                   :  2;
+       u64 reserved_262_319            : 58;
+       u64 reserved_320_383            : 64; /* W5 */
+       u64 reserved_384_447            : 64; /* W6 */
+       u64 reserved_448_511            : 64; /* W7 */
+       u64 padding[8];
+};
+
+static_assert(sizeof(struct nix_cn20k_sq_ctx_s) == NIX_MAX_CTX_SIZE);
+
+struct nix_cn20k_rq_ctx_s {
+       u64 ena                         :  1;
+       u64 sso_ena                     :  1;
+       u64 ipsech_ena                  :  1;
+       u64 ena_wqwd                    :  1;
+       u64 cq                          : 20;
+       u64 reserved_24_34              : 11;
+       u64 port_il4_dis                :  1;
+       u64 port_ol4_dis                :  1;
+       u64 lenerr_dis                  :  1;
+       u64 csum_il4_dis                :  1;
+       u64 csum_ol4_dis                :  1;
+       u64 len_il4_dis                 :  1;
+       u64 len_il3_dis                 :  1;
+       u64 len_ol4_dis                 :  1;
+       u64 len_ol3_dis                 :  1;
+       u64 wqe_aura                    : 20;
+       u64 spb_aura                    : 20;
+       u64 lpb_aura                    : 20;
+       u64 sso_grp                     : 10;
+       u64 sso_tt                      :  2;
+       u64 pb_caching                  :  2;
+       u64 wqe_caching                 :  1;
+       u64 xqe_drop_ena                :  1;
+       u64 spb_drop_ena                :  1;
+       u64 lpb_drop_ena                :  1;
+       u64 pb_stashing                 :  1;
+       u64 ipsecd_drop_en              :  1;
+       u64 chi_ena                     :  1;
+       u64 reserved_125_127            :  3;
+       u64 band_prof_id_l              : 10;
+       u64 sso_fc_ena                  :  1;
+       u64 policer_ena                 :  1;
+       u64 spb_sizem1                  :  6;
+       u64 wqe_skip                    :  2;
+       u64 spb_high_sizem1             :  3;
+       u64 spb_ena                     :  1;
+       u64 lpb_sizem1                  : 12;
+       u64 first_skip                  :  7;
+       u64 reserved_171_171            :  1;
+       u64 later_skip                  :  6;
+       u64 xqe_imm_size                :  6;
+       u64 band_prof_id_h              :  4;
+       u64 reserved_188_189            :  2;
+       u64 xqe_imm_copy                :  1;
+       u64 xqe_hdr_split               :  1;
+       u64 xqe_drop                    :  8;
+       u64 xqe_pass                    :  8;
+       u64 wqe_pool_drop               :  8;
+       u64 wqe_pool_pass               :  8;
+       u64 spb_aura_drop               :  8;
+       u64 spb_aura_pass               :  8;
+       u64 spb_pool_drop               :  8;
+       u64 spb_pool_pass               :  8;
+       u64 lpb_aura_drop               :  8;
+       u64 lpb_aura_pass               :  8;
+       u64 lpb_pool_drop               :  8;
+       u64 lpb_pool_pass               :  8;
+       u64 reserved_288_291            :  4;
+       u64 rq_int                      :  8;
+       u64 rq_int_ena                  :  8;
+       u64 qint_idx                    :  7;
+       u64 reserved_315_319            :  5;
+       u64 ltag                        : 24;
+       u64 good_utag                   :  8;
+       u64 bad_utag                    :  8;
+       u64 flow_tagw                   :  6;
+       u64 ipsec_vwqe                  :  1;
+       u64 vwqe_ena                    :  1;
+       u64 vtime_wait                  :  8;
+       u64 max_vsize_exp               :  4;
+       u64 vwqe_skip                   :  2;
+       u64 reserved_382_383            :  2;
+       u64 octs                        : 48;
+       u64 reserved_432_447            : 16;
+       u64 pkts                        : 48;
+       u64 reserved_496_511            : 16;
+       u64 drop_octs                   : 48;
+       u64 reserved_560_575            : 16;
+       u64 drop_pkts                   : 48;
+       u64 reserved_624_639            : 16;
+       u64 re_pkts                     : 48;
+       u64 reserved_688_703            : 16;
+       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 nix_cn20k_rq_ctx_s) == NIX_MAX_CTX_SIZE);
+
 #endif
index 933073cd228041b9e92b244347ebe21f4c0cb47e..01086c52e78d4cef4119fd10c0dd73eef1691bc2 100644 (file)
@@ -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)                             \
@@ -940,6 +942,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;
index b5828334192324cbf733892b277e7b280e6e17f4..e85dac2c806d9fb0fb033abb1035428fa937edbf 100644 (file)
@@ -498,6 +498,14 @@ struct channel_fwdata {
        u8 reserved[RVU_CHANL_INFO_RESERVED];
 };
 
+struct altaf_intr_notify {
+       unsigned long flr_pf_bmap[2];
+       unsigned long flr_vf_bmap[2];
+       unsigned long gint_paddr;
+       unsigned long gint_iova_addr;
+       unsigned long reserved[6];
+};
+
 struct rvu_fwdata {
 #define RVU_FWDATA_HEADER_MAGIC        0xCFDA  /* Custom Firmware Data*/
 #define RVU_FWDATA_VERSION     0x0001
@@ -517,7 +525,8 @@ struct rvu_fwdata {
        u32 ptp_ext_clk_rate;
        u32 ptp_ext_tstamp;
        struct channel_fwdata channel_data;
-#define FWDATA_RESERVED_MEM 958
+       struct altaf_intr_notify altaf_intr_info;
+#define FWDATA_RESERVED_MEM 946
        u64 reserved[FWDATA_RESERVED_MEM];
 #define CGX_MAX         9
 #define CGX_LMACS_MAX   4
@@ -648,6 +657,7 @@ struct rvu {
 
        struct mutex            mbox_lock; /* Serialize mbox up and down msgs */
        u16                     rep_pcifunc;
+       bool                    altaf_ready;
        int                     rep_cnt;
        u16                     *rep2pfvf_map;
        u8                      rep_mode;
@@ -1032,6 +1042,9 @@ 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);
 void rvu_block_bcast_xon(struct rvu *rvu, int blkaddr);
+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);
index 26dc0fbeafa67fe573660d9439360a730aa3fc99..d156d124f07960edb15d1fffe0c65dcfb09feca4 100644 (file)
@@ -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;