From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 59E4445954; Tue, 10 Sep 2024 10:59:50 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DD4FD427E1; Tue, 10 Sep 2024 10:59:39 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id 23A34427B6 for ; Tue, 10 Sep 2024 10:59:38 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 48A4fnVo029408 for ; Tue, 10 Sep 2024 01:59:38 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=pfpt0220; bh=R tmzSHth7bmwVukEjJEgtxLHKY/FAJCD/kGS2ckrYMs=; b=cFKteN+PFjVqUufWT tm91xireOSJMfDrd8K+4BT9wrAgvk2TWJaxlhoM3/kEMGok/JgiI4wNhgvpzjnhS TWjXUYcx/MQAhG0oXF1fpxC/Nyj+2w/lmTsmVUIZex5vUrf3BAWVJhC6yCqsCx1J m2ktPA2xpGL5MBWxvIkZ96URSPLSk7bjjjVMSyD5UE+7rtZDZne3x9xZs6aankbO HfCL9Brj4Jrgn4R1Bp4awzRie0nreD5WAasWBVPEvVWrtHW23cQlPmnos7e2+N1z ztrmR7G6g8RN+Ajc1iD1UdRc8svPvDtHuIJxwdW+aybC0Ar3hOjBxa4eI/5kQSQj mNxsw== Received: from dc5-exch05.marvell.com ([199.233.59.128]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 41gygtg1dh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 10 Sep 2024 01:59:37 -0700 (PDT) Received: from DC5-EXCH05.marvell.com (10.69.176.209) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Tue, 10 Sep 2024 01:59:37 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH05.marvell.com (10.69.176.209) with Microsoft SMTP Server id 15.2.1544.4 via Frontend Transport; Tue, 10 Sep 2024 01:59:36 -0700 Received: from hyd1588t430.caveonetworks.com (unknown [10.29.52.204]) by maili.marvell.com (Postfix) with ESMTP id 0A7303F709E; Tue, 10 Sep 2024 01:59:33 -0700 (PDT) From: Nithin Dabilpuram To: , Nithin Dabilpuram , "Kiran Kumar K" , Sunil Kumar Kori , Satha Rao , Harman Kalra CC: , Ashwin Sekhar T K Subject: [PATCH 03/33] common/cnxk: use new NPA aq enq mbox for cn20k Date: Tue, 10 Sep 2024 14:28:39 +0530 Message-ID: <20240910085909.1514457-4-ndabilpuram@marvell.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240910085909.1514457-1-ndabilpuram@marvell.com> References: <20240910085909.1514457-1-ndabilpuram@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: JqM9-ewrR1O1XycYk9Jp5O8HWEICoe5T X-Proofpoint-GUID: JqM9-ewrR1O1XycYk9Jp5O8HWEICoe5T X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-06_09,2024-09-06_01,2024-09-02_01 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Ashwin Sekhar T K A new mbox npa_cn20k_aq_enq_req has been added for cn20k. Use this mbox for NPA configurations. Note that the size of these new mbox request and response remains same when compared to the older mboxes. Also the new contexts npa_cn20k_aura_s/ npa_cn20k_pool_s which has been added for cn20k are also same in size as older npa_aura_s/npa_pool_s. So, we will be able to typecast these structures into each other for most cases. Only the fields that have changed in width/positions need to be taken care of. Signed-off-by: Ashwin Sekhar T K --- drivers/common/cnxk/hw/npa.h | 164 ++++++++++++++++++++++++--- drivers/common/cnxk/roc_mbox.h | 32 ++++++ drivers/common/cnxk/roc_nix_debug.c | 9 +- drivers/common/cnxk/roc_nix_fc.c | 54 ++++++--- drivers/common/cnxk/roc_nix_tm_ops.c | 15 ++- drivers/common/cnxk/roc_npa.c | 100 ++++++++++++++-- drivers/common/cnxk/roc_npa_debug.c | 17 ++- 7 files changed, 339 insertions(+), 52 deletions(-) diff --git a/drivers/common/cnxk/hw/npa.h b/drivers/common/cnxk/hw/npa.h index 891a1b2b5f..4fd1f9a64b 100644 --- a/drivers/common/cnxk/hw/npa.h +++ b/drivers/common/cnxk/hw/npa.h @@ -216,10 +216,10 @@ struct npa_aura_op_wdata_s { uint64_t drop : 1; }; -/* NPA aura context structure */ +/* NPA aura context structure [CN9K, CN10K] */ struct npa_aura_s { uint64_t pool_addr : 64; /* W0 */ - uint64_t ena : 1; + uint64_t ena : 1; /* W1 */ uint64_t rsvd_66_65 : 2; uint64_t pool_caching : 1; uint64_t pool_way_mask : 16; @@ -233,24 +233,24 @@ struct npa_aura_s { uint64_t shift : 6; uint64_t rsvd_119_118 : 2; uint64_t avg_level : 8; - uint64_t count : 36; + uint64_t count : 36; /* W2 */ uint64_t rsvd_167_164 : 4; uint64_t nix0_bpid : 9; uint64_t rsvd_179_177 : 3; uint64_t nix1_bpid : 9; uint64_t rsvd_191_189 : 3; - uint64_t limit : 36; + uint64_t limit : 36; /* W3 */ uint64_t rsvd_231_228 : 4; uint64_t bp : 8; uint64_t rsvd_242_240 : 3; - uint64_t fc_be : 1; /* [CN10K, .) */ + uint64_t fc_be : 1; /* [CN10K] */ uint64_t fc_ena : 1; uint64_t fc_up_crossing : 1; uint64_t fc_stype : 2; uint64_t fc_hyst_bits : 4; uint64_t rsvd_255_252 : 4; uint64_t fc_addr : 64; /* W4 */ - uint64_t pool_drop : 8; + uint64_t pool_drop : 8; /* W5 */ uint64_t update_time : 16; uint64_t err_int : 8; uint64_t err_int_ena : 8; @@ -262,17 +262,17 @@ struct npa_aura_s { uint64_t rsvd_371 : 1; uint64_t err_qint_idx : 7; uint64_t rsvd_383_379 : 5; - uint64_t thresh : 36; + uint64_t thresh : 36; /* W6 */ uint64_t rsvd_423_420 : 4; - uint64_t fc_msh_dst : 11; /* [CN10K, .) */ + uint64_t fc_msh_dst : 11; /* [CN10K] */ uint64_t rsvd_447_435 : 13; uint64_t rsvd_511_448 : 64; /* W7 */ }; -/* NPA pool context structure */ +/* NPA pool context structure [CN9K, CN10K] */ struct npa_pool_s { uint64_t stack_base : 64; /* W0 */ - uint64_t ena : 1; + uint64_t ena : 1; /* W1 */ uint64_t nat_align : 1; uint64_t rsvd_67_66 : 2; uint64_t stack_caching : 1; @@ -282,11 +282,11 @@ struct npa_pool_s { uint64_t rsvd_103_100 : 4; uint64_t buf_size : 11; uint64_t rsvd_127_115 : 13; - uint64_t stack_max_pages : 32; + uint64_t stack_max_pages : 32; /* W2 */ uint64_t stack_pages : 32; - uint64_t op_pc : 48; + uint64_t op_pc : 48; /* W3 */ uint64_t rsvd_255_240 : 16; - uint64_t stack_offset : 4; + uint64_t stack_offset : 4; /* W4 */ uint64_t rsvd_263_260 : 4; uint64_t shift : 6; uint64_t rsvd_271_270 : 2; @@ -296,14 +296,14 @@ struct npa_pool_s { uint64_t fc_stype : 2; uint64_t fc_hyst_bits : 4; uint64_t fc_up_crossing : 1; - uint64_t fc_be : 1; /* [CN10K, .) */ + uint64_t fc_be : 1; /* [CN10K] */ uint64_t rsvd_299_298 : 2; uint64_t update_time : 16; uint64_t rsvd_319_316 : 4; uint64_t fc_addr : 64; /* W5 */ uint64_t ptr_start : 64; /* W6 */ uint64_t ptr_end : 64; /* W7 */ - uint64_t rsvd_535_512 : 24; + uint64_t rsvd_535_512 : 24; /* W8 */ uint64_t err_int : 8; uint64_t err_int_ena : 8; uint64_t thresh_int : 1; @@ -314,9 +314,9 @@ struct npa_pool_s { uint64_t rsvd_563 : 1; uint64_t err_qint_idx : 7; uint64_t rsvd_575_571 : 5; - uint64_t thresh : 36; + uint64_t thresh : 36; /* W9 */ uint64_t rsvd_615_612 : 4; - uint64_t fc_msh_dst : 11; /* [CN10K, .) */ + uint64_t fc_msh_dst : 11; /* [CN10K] */ uint64_t rsvd_639_627 : 13; uint64_t rsvd_703_640 : 64; /* W10 */ uint64_t rsvd_767_704 : 64; /* W11 */ @@ -326,6 +326,136 @@ struct npa_pool_s { uint64_t rsvd_1023_960 : 64; /* W15 */ }; +/* NPA aura context structure [CN20K] */ +struct npa_cn20k_aura_s { + uint64_t pool_addr : 64; /* W0 */ + uint64_t ena : 1; /* W1 */ + uint64_t rsvd_66_65 : 2; + uint64_t pool_caching : 1; + uint64_t rsvd_68 : 16; + uint64_t avg_con : 9; + uint64_t rsvd_93 : 1; + uint64_t pool_drop_ena : 1; + uint64_t aura_drop_ena : 1; + uint64_t bp_ena : 1; + uint64_t rsvd_103_97 : 7; + uint64_t aura_drop : 8; + uint64_t shift : 6; + uint64_t rsvd_119_118 : 2; + uint64_t avg_level : 8; + uint64_t count : 36; /* W2 */ + uint64_t rsvd_167_164 : 4; + uint64_t bpid : 12; + uint64_t rsvd_191_180 : 12; + uint64_t limit : 36; /* W3 */ + uint64_t rsvd_231_228 : 4; + uint64_t bp : 7; + uint64_t rsvd_243_239 : 5; + uint64_t fc_ena : 1; + uint64_t fc_up_crossing : 1; + uint64_t fc_stype : 2; + uint64_t fc_hyst_bits : 4; + uint64_t rsvd_255_252 : 4; + uint64_t fc_addr : 64; /* W4 */ + uint64_t pool_drop : 8; /* W5 */ + uint64_t update_time : 16; + uint64_t err_int : 8; + uint64_t err_int_ena : 8; + uint64_t thresh_int : 1; + uint64_t thresh_int_ena : 1; + uint64_t thresh_up : 1; + uint64_t rsvd_363 : 1; + uint64_t thresh_qint_idx : 7; + uint64_t rsvd_371 : 1; + uint64_t err_qint_idx : 7; + uint64_t rsvd_383_379 : 5; + uint64_t thresh : 36; /* W6*/ + uint64_t rsvd_423_420 : 4; + uint64_t fc_msh_dst : 11; + uint64_t rsvd_438_435 : 4; + uint64_t op_dpc_ena : 1; + uint64_t op_dpc_set : 6; + uint64_t stream_ctx : 1; + uint64_t unified_ctx : 1; + uint64_t rsvd_511_448 : 64; /* W7 */ +}; + +/* NPA pool context structure [CN20K] */ +struct npa_cn20k_pool_s { + uint64_t stack_base : 64; /* W0 */ + uint64_t ena : 1; /* W1 */ + uint64_t nat_align : 1; + uint64_t rsvd_67_66 : 2; + uint64_t stack_caching : 1; + uint64_t rsvd_87_69 : 19; + uint64_t buf_offset : 12; + uint64_t rsvd_103_100 : 4; + uint64_t buf_size : 12; + uint64_t rsvd_119_116 : 4; + uint64_t ref_cnt_prof : 3; + uint64_t rsvd_127_123 : 5; + uint64_t stack_max_pages : 32; /* W2 */ + uint64_t stack_pages : 32; + uint64_t bp_0 : 7; /* W3 */ + 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; + uint64_t stack_offset : 4; /* W4 */ + uint64_t rsvd_263_260 : 4; + uint64_t shift : 6; + uint64_t rsvd_271_270 : 2; + uint64_t avg_level : 8; + uint64_t avg_con : 9; + uint64_t fc_ena : 1; + uint64_t fc_stype : 2; + uint64_t fc_hyst_bits : 4; + uint64_t fc_up_crossing : 1; + uint64_t rsvd_299_297 : 3; + uint64_t update_time : 16; + uint64_t rsvd_319_316 : 4; + uint64_t fc_addr : 64; /* W5 */ + uint64_t ptr_start : 64; /* W6 */ + uint64_t ptr_end : 64; /* W7 */ + uint64_t bpid_0 : 12; /* W8 */ + uint64_t rsvd_535_524 : 12; + uint64_t err_int : 8; + uint64_t err_int_ena : 8; + uint64_t thresh_int : 1; + uint64_t thresh_int_ena : 1; + uint64_t thresh_up : 1; + uint64_t rsvd_555 : 1; + uint64_t thresh_qint_idx : 7; + uint64_t rsvd_563 : 1; + uint64_t err_qint_idx : 7; + uint64_t rsvd_575_571 : 5; + uint64_t thresh : 36; /* W9 */ + uint64_t rsvd_615_612 : 4; + uint64_t fc_msh_dst : 11; + uint64_t rsvd_630_627 : 4; + uint64_t op_dpc_ena : 1; + uint64_t op_dpc_set : 6; + uint64_t stream_ctx : 1; + uint64_t rsvd_639 : 1; + uint64_t rsvd_703_640 : 64; /* W10 */ + uint64_t rsvd_767_704 : 64; /* W11 */ + uint64_t rsvd_831_768 : 64; /* W12 */ + uint64_t rsvd_895_832 : 64; /* W13 */ + uint64_t rsvd_959_896 : 64; /* W14 */ + uint64_t rsvd_1023_960 : 64; /* W15 */ +}; + /* NPA queue interrupt context hardware structure */ struct npa_qint_hw_s { uint32_t count : 22; diff --git a/drivers/common/cnxk/roc_mbox.h b/drivers/common/cnxk/roc_mbox.h index f1a3371ef9..9a9dcbdbda 100644 --- a/drivers/common/cnxk/roc_mbox.h +++ b/drivers/common/cnxk/roc_mbox.h @@ -119,6 +119,8 @@ struct mbox_msghdr { 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) */ \ M(SSO_LF_ALLOC, 0x600, sso_lf_alloc, sso_lf_alloc_req, \ sso_lf_alloc_rsp) \ @@ -1325,6 +1327,36 @@ struct npa_aq_enq_rsp { }; }; +struct npa_cn20k_aq_enq_req { + struct mbox_msghdr hdr; + uint32_t __io aura_id; + uint8_t __io ctype; + uint8_t __io op; + union { + /* Valid when op == WRITE/INIT and ctype == AURA */ + __io struct npa_cn20k_aura_s aura; + /* Valid when op == WRITE/INIT and ctype == POOL */ + __io 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 */ + __io struct npa_cn20k_aura_s aura_mask; + /* Valid when op == WRITE and ctype == POOL */ + __io 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 */ + __io struct npa_cn20k_aura_s aura; + /* Valid when op == READ and ctype == POOL */ + __io struct npa_cn20k_pool_s pool; + }; +}; + /* Disable all contexts of type 'ctype' */ struct hwctx_disable_req { struct mbox_msghdr hdr; diff --git a/drivers/common/cnxk/roc_nix_debug.c b/drivers/common/cnxk/roc_nix_debug.c index 26546f9297..2e91470c09 100644 --- a/drivers/common/cnxk/roc_nix_debug.c +++ b/drivers/common/cnxk/roc_nix_debug.c @@ -690,6 +690,7 @@ int roc_nix_queues_ctx_dump(struct roc_nix *roc_nix, FILE *file) { struct nix *nix = roc_nix_to_nix_priv(roc_nix); + struct npa_cn20k_aq_enq_req *npa_aq_cn20k; int rc = -1, q, rq = nix->nb_rx_queues; struct npa_aq_enq_rsp *npa_rsp; struct npa_aq_enq_req *npa_aq; @@ -772,8 +773,12 @@ roc_nix_queues_ctx_dump(struct roc_nix *roc_nix, FILE *file) continue; } - /* Dump SQB Aura minimal info */ - npa_aq = mbox_alloc_msg_npa_aq_enq(mbox_get(npa_lf->mbox)); + if (roc_model_is_cn20k()) { + npa_aq_cn20k = mbox_alloc_msg_npa_cn20k_aq_enq(mbox_get(npa_lf->mbox)); + npa_aq = (struct npa_aq_enq_req *)npa_aq_cn20k; /* Common fields */ + } else { + npa_aq = mbox_alloc_msg_npa_aq_enq(mbox_get(npa_lf->mbox)); + } if (npa_aq == NULL) { rc = -ENOSPC; mbox_put(npa_lf->mbox); diff --git a/drivers/common/cnxk/roc_nix_fc.c b/drivers/common/cnxk/roc_nix_fc.c index 12bfb9816b..2f72e67993 100644 --- a/drivers/common/cnxk/roc_nix_fc.c +++ b/drivers/common/cnxk/roc_nix_fc.c @@ -158,6 +158,8 @@ static int nix_fc_rq_config_get(struct roc_nix *roc_nix, struct roc_nix_fc_cfg *fc_cfg) { struct nix *nix = roc_nix_to_nix_priv(roc_nix); + struct npa_cn20k_aq_enq_req *npa_req_cn20k; + struct npa_cn20k_aq_enq_rsp *npa_rsp_cn20k; struct dev *dev = &nix->dev; struct mbox *mbox = mbox_get(dev->mbox); struct nix_aq_enq_rsp *rsp; @@ -195,24 +197,44 @@ nix_fc_rq_config_get(struct roc_nix *roc_nix, struct roc_nix_fc_cfg *fc_cfg) if (rc) goto exit; - npa_req = mbox_alloc_msg_npa_aq_enq(mbox); - if (!npa_req) { - rc = -ENOSPC; - goto exit; + if (roc_model_is_cn20k()) { + npa_req_cn20k = mbox_alloc_msg_npa_cn20k_aq_enq(mbox); + if (!npa_req_cn20k) { + rc = -ENOSPC; + goto exit; + } + + npa_req_cn20k->aura_id = rsp->rq.lpb_aura; + npa_req_cn20k->ctype = NPA_AQ_CTYPE_AURA; + npa_req_cn20k->op = NPA_AQ_INSTOP_READ; + + rc = mbox_process_msg(mbox, (void *)&npa_rsp_cn20k); + if (rc) + goto exit; + + fc_cfg->cq_cfg.cq_drop = npa_rsp_cn20k->aura.bp; + fc_cfg->cq_cfg.enable = npa_rsp_cn20k->aura.bp_ena; + fc_cfg->type = ROC_NIX_FC_RQ_CFG; + } else { + npa_req = mbox_alloc_msg_npa_aq_enq(mbox); + if (!npa_req) { + rc = -ENOSPC; + goto exit; + } + + npa_req->aura_id = rsp->rq.lpb_aura; + npa_req->ctype = NPA_AQ_CTYPE_AURA; + npa_req->op = NPA_AQ_INSTOP_READ; + + rc = mbox_process_msg(mbox, (void *)&npa_rsp); + if (rc) + goto exit; + + fc_cfg->cq_cfg.cq_drop = npa_rsp->aura.bp; + fc_cfg->cq_cfg.enable = npa_rsp->aura.bp_ena; + fc_cfg->type = ROC_NIX_FC_RQ_CFG; } - npa_req->aura_id = rsp->rq.lpb_aura; - npa_req->ctype = NPA_AQ_CTYPE_AURA; - npa_req->op = NPA_AQ_INSTOP_READ; - - rc = mbox_process_msg(mbox, (void *)&npa_rsp); - if (rc) - goto exit; - - fc_cfg->cq_cfg.cq_drop = npa_rsp->aura.bp; - fc_cfg->cq_cfg.enable = npa_rsp->aura.bp_ena; - fc_cfg->type = ROC_NIX_FC_RQ_CFG; - exit: mbox_put(mbox); return rc; diff --git a/drivers/common/cnxk/roc_nix_tm_ops.c b/drivers/common/cnxk/roc_nix_tm_ops.c index 9f3870a311..8144675f89 100644 --- a/drivers/common/cnxk/roc_nix_tm_ops.c +++ b/drivers/common/cnxk/roc_nix_tm_ops.c @@ -8,6 +8,7 @@ int roc_nix_tm_sq_aura_fc(struct roc_nix_sq *sq, bool enable) { + struct npa_cn20k_aq_enq_req *req_cn20k; struct npa_aq_enq_req *req; struct npa_aq_enq_rsp *rsp; uint64_t aura_handle; @@ -25,7 +26,12 @@ roc_nix_tm_sq_aura_fc(struct roc_nix_sq *sq, bool enable) mbox = mbox_get(lf->mbox); /* Set/clear sqb aura fc_ena */ aura_handle = sq->aura_handle; - req = mbox_alloc_msg_npa_aq_enq(mbox); + if (roc_model_is_cn20k()) { + req_cn20k = mbox_alloc_msg_npa_cn20k_aq_enq(mbox); + req = (struct npa_aq_enq_req *)req_cn20k; + } else { + req = mbox_alloc_msg_npa_aq_enq(mbox); + } if (req == NULL) goto exit; @@ -52,7 +58,12 @@ roc_nix_tm_sq_aura_fc(struct roc_nix_sq *sq, bool enable) /* Read back npa aura ctx */ if (enable) { - req = mbox_alloc_msg_npa_aq_enq(mbox); + if (roc_model_is_cn20k()) { + req_cn20k = mbox_alloc_msg_npa_cn20k_aq_enq(mbox); + req = (struct npa_aq_enq_req *)req_cn20k; + } else { + req = mbox_alloc_msg_npa_aq_enq(mbox); + } if (req == NULL) { rc = -ENOSPC; goto exit; diff --git a/drivers/common/cnxk/roc_npa.c b/drivers/common/cnxk/roc_npa.c index 6c14c49901..934d7361a9 100644 --- a/drivers/common/cnxk/roc_npa.c +++ b/drivers/common/cnxk/roc_npa.c @@ -76,6 +76,7 @@ static int npa_aura_pool_init(struct mbox *m_box, uint32_t aura_id, struct npa_aura_s *aura, struct npa_pool_s *pool) { + struct npa_cn20k_aq_enq_req *aura_init_req_cn20k, *pool_init_req_cn20k; struct npa_aq_enq_req *aura_init_req, *pool_init_req; struct npa_aq_enq_rsp *aura_init_rsp, *pool_init_rsp; struct mbox_dev *mdev = &m_box->dev[0]; @@ -83,7 +84,12 @@ npa_aura_pool_init(struct mbox *m_box, uint32_t aura_id, struct npa_aura_s *aura struct mbox *mbox; mbox = mbox_get(m_box); - aura_init_req = mbox_alloc_msg_npa_aq_enq(mbox); + if (roc_model_is_cn20k()) { + aura_init_req_cn20k = mbox_alloc_msg_npa_cn20k_aq_enq(mbox); + aura_init_req = (struct npa_aq_enq_req *)aura_init_req_cn20k; + } else { + aura_init_req = mbox_alloc_msg_npa_aq_enq(mbox); + } if (aura_init_req == NULL) goto exit; aura_init_req->aura_id = aura_id; @@ -91,6 +97,12 @@ npa_aura_pool_init(struct mbox *m_box, uint32_t aura_id, struct npa_aura_s *aura aura_init_req->op = NPA_AQ_INSTOP_INIT; mbox_memcpy(&aura_init_req->aura, aura, sizeof(*aura)); + if (roc_model_is_cn20k()) { + pool_init_req_cn20k = mbox_alloc_msg_npa_cn20k_aq_enq(mbox); + pool_init_req = (struct npa_aq_enq_req *)pool_init_req_cn20k; + } else { + pool_init_req = mbox_alloc_msg_npa_aq_enq(mbox); + } pool_init_req = mbox_alloc_msg_npa_aq_enq(mbox); if (pool_init_req == NULL) goto exit; @@ -121,13 +133,19 @@ npa_aura_pool_init(struct mbox *m_box, uint32_t aura_id, struct npa_aura_s *aura static int npa_aura_init(struct mbox *m_box, uint32_t aura_id, struct npa_aura_s *aura) { + struct npa_cn20k_aq_enq_req *aura_init_req_cn20k; struct npa_aq_enq_req *aura_init_req; struct npa_aq_enq_rsp *aura_init_rsp; struct mbox *mbox; int rc = -ENOSPC; mbox = mbox_get(m_box); - aura_init_req = mbox_alloc_msg_npa_aq_enq(mbox); + if (roc_model_is_cn20k()) { + aura_init_req_cn20k = mbox_alloc_msg_npa_cn20k_aq_enq(mbox); + aura_init_req = (struct npa_aq_enq_req *)aura_init_req_cn20k; + } else { + aura_init_req = mbox_alloc_msg_npa_aq_enq(mbox); + } if (aura_init_req == NULL) goto exit; aura_init_req->aura_id = aura_id; @@ -151,6 +169,7 @@ npa_aura_init(struct mbox *m_box, uint32_t aura_id, struct npa_aura_s *aura) static int npa_aura_pool_fini(struct mbox *m_box, uint32_t aura_id, uint64_t aura_handle) { + struct npa_cn20k_aq_enq_req *aura_req_cn20k, *pool_req_cn20k; struct npa_aq_enq_req *aura_req, *pool_req; struct npa_aq_enq_rsp *aura_rsp, *pool_rsp; struct mbox_dev *mdev = &m_box->dev[0]; @@ -168,7 +187,12 @@ npa_aura_pool_fini(struct mbox *m_box, uint32_t aura_id, uint64_t aura_handle) } while (ptr); mbox = mbox_get(m_box); - pool_req = mbox_alloc_msg_npa_aq_enq(mbox); + if (roc_model_is_cn20k()) { + pool_req_cn20k = mbox_alloc_msg_npa_cn20k_aq_enq(mbox); + pool_req = (struct npa_aq_enq_req *)pool_req_cn20k; + } else { + pool_req = mbox_alloc_msg_npa_aq_enq(mbox); + } if (pool_req == NULL) goto exit; pool_req->aura_id = aura_id; @@ -177,7 +201,12 @@ npa_aura_pool_fini(struct mbox *m_box, uint32_t aura_id, uint64_t aura_handle) pool_req->pool.ena = 0; pool_req->pool_mask.ena = ~pool_req->pool_mask.ena; - aura_req = mbox_alloc_msg_npa_aq_enq(mbox); + if (roc_model_is_cn20k()) { + aura_req_cn20k = mbox_alloc_msg_npa_cn20k_aq_enq(mbox); + aura_req = (struct npa_aq_enq_req *)aura_req_cn20k; + } else { + aura_req = mbox_alloc_msg_npa_aq_enq(mbox); + } if (aura_req == NULL) goto exit; aura_req->aura_id = aura_id; @@ -185,8 +214,18 @@ npa_aura_pool_fini(struct mbox *m_box, uint32_t aura_id, uint64_t aura_handle) aura_req->op = NPA_AQ_INSTOP_WRITE; aura_req->aura.ena = 0; aura_req->aura_mask.ena = ~aura_req->aura_mask.ena; - aura_req->aura.bp_ena = 0; - aura_req->aura_mask.bp_ena = ~aura_req->aura_mask.bp_ena; + if (roc_model_is_cn20k()) { + __io struct npa_cn20k_aura_s *aura_cn20k, *aura_mask_cn20k; + + /* The bit positions/width of bp_ena has changed in cn20k */ + aura_cn20k = (__io struct npa_cn20k_aura_s *)&aura_req->aura; + aura_cn20k->bp_ena = 0; + aura_mask_cn20k = (__io struct npa_cn20k_aura_s *)&aura_req->aura_mask; + aura_mask_cn20k->bp_ena = ~aura_mask_cn20k->bp_ena; + } else { + aura_req->aura.bp_ena = 0; + aura_req->aura_mask.bp_ena = ~aura_req->aura_mask.bp_ena; + } rc = mbox_process(mbox); if (rc < 0) @@ -204,6 +243,12 @@ npa_aura_pool_fini(struct mbox *m_box, uint32_t aura_id, uint64_t aura_handle) goto exit; } + if (roc_model_is_cn20k()) { + /* In cn20k, NPA does not use NDC */ + rc = 0; + goto exit; + } + /* Sync NDC-NPA for LF */ ndc_req = mbox_alloc_msg_ndc_sync_op(mbox); if (ndc_req == NULL) { @@ -226,6 +271,7 @@ npa_aura_pool_fini(struct mbox *m_box, uint32_t aura_id, uint64_t aura_handle) static int npa_aura_fini(struct mbox *m_box, uint32_t aura_id) { + struct npa_cn20k_aq_enq_req *aura_req_cn20k; struct npa_aq_enq_req *aura_req; struct npa_aq_enq_rsp *aura_rsp; struct ndc_sync_op *ndc_req; @@ -236,7 +282,12 @@ npa_aura_fini(struct mbox *m_box, uint32_t aura_id) plt_delay_us(10); mbox = mbox_get(m_box); - aura_req = mbox_alloc_msg_npa_aq_enq(mbox); + if (roc_model_is_cn20k()) { + aura_req_cn20k = mbox_alloc_msg_npa_cn20k_aq_enq(mbox); + aura_req = (struct npa_aq_enq_req *)aura_req_cn20k; + } else { + aura_req = mbox_alloc_msg_npa_aq_enq(mbox); + } if (aura_req == NULL) goto exit; aura_req->aura_id = aura_id; @@ -254,6 +305,12 @@ npa_aura_fini(struct mbox *m_box, uint32_t aura_id) goto exit; } + if (roc_model_is_cn20k()) { + /* In cn20k, NPA does not use NDC */ + rc = 0; + goto exit; + } + /* Sync NDC-NPA for LF */ ndc_req = mbox_alloc_msg_ndc_sync_op(mbox); if (ndc_req == NULL) { @@ -335,6 +392,7 @@ roc_npa_pool_op_pc_reset(uint64_t aura_handle) int roc_npa_aura_drop_set(uint64_t aura_handle, uint64_t limit, bool ena) { + struct npa_cn20k_aq_enq_req *aura_req_cn20k; struct npa_aq_enq_req *aura_req; struct npa_lf *lf; struct mbox *mbox; @@ -344,7 +402,12 @@ roc_npa_aura_drop_set(uint64_t aura_handle, uint64_t limit, bool ena) if (lf == NULL) return NPA_ERR_DEVICE_NOT_BOUNDED; mbox = mbox_get(lf->mbox); - aura_req = mbox_alloc_msg_npa_aq_enq(mbox); + if (roc_model_is_cn20k()) { + aura_req_cn20k = mbox_alloc_msg_npa_cn20k_aq_enq(mbox); + aura_req = (struct npa_aq_enq_req *)aura_req_cn20k; + } else { + aura_req = mbox_alloc_msg_npa_aq_enq(mbox); + } if (aura_req == NULL) { rc = -ENOMEM; goto exit; @@ -723,6 +786,7 @@ roc_npa_aura_create(uint64_t *aura_handle, uint32_t block_count, int roc_npa_aura_limit_modify(uint64_t aura_handle, uint16_t aura_limit) { + struct npa_cn20k_aq_enq_req *aura_req_cn20k; struct npa_aq_enq_req *aura_req; struct npa_lf *lf; struct mbox *mbox; @@ -733,7 +797,12 @@ roc_npa_aura_limit_modify(uint64_t aura_handle, uint16_t aura_limit) return NPA_ERR_DEVICE_NOT_BOUNDED; mbox = mbox_get(lf->mbox); - aura_req = mbox_alloc_msg_npa_aq_enq(mbox); + if (roc_model_is_cn20k()) { + aura_req_cn20k = mbox_alloc_msg_npa_cn20k_aq_enq(mbox); + aura_req = (struct npa_aq_enq_req *)aura_req_cn20k; + } else { + aura_req = mbox_alloc_msg_npa_aq_enq(mbox); + } if (aura_req == NULL) { rc = -ENOMEM; goto exit; @@ -834,12 +903,13 @@ int roc_npa_pool_range_update_check(uint64_t aura_handle) { uint64_t aura_id = roc_npa_aura_handle_to_aura(aura_handle); - struct npa_lf *lf; - struct npa_aura_lim *lim; + struct npa_cn20k_aq_enq_req *req_cn20k; __io struct npa_pool_s *pool; struct npa_aq_enq_req *req; struct npa_aq_enq_rsp *rsp; + struct npa_aura_lim *lim; struct mbox *mbox; + struct npa_lf *lf; int rc; lf = idev_npa_obj_get(); @@ -849,7 +919,12 @@ roc_npa_pool_range_update_check(uint64_t aura_handle) lim = lf->aura_lim; mbox = mbox_get(lf->mbox); - req = mbox_alloc_msg_npa_aq_enq(mbox); + if (roc_model_is_cn20k()) { + req_cn20k = mbox_alloc_msg_npa_cn20k_aq_enq(mbox); + req = (struct npa_aq_enq_req *)req_cn20k; + } else { + req = mbox_alloc_msg_npa_aq_enq(mbox); + } if (req == NULL) { rc = -ENOSPC; goto exit; @@ -903,6 +978,7 @@ int roc_npa_aura_bp_configure(uint64_t aura_handle, uint16_t bpid, uint8_t bp_intf, uint8_t bp_thresh, bool enable) { + /* TODO: Add support for CN20K */ uint32_t aura_id = roc_npa_aura_handle_to_aura(aura_handle); struct npa_lf *lf = idev_npa_obj_get(); struct npa_aq_enq_req *req; diff --git a/drivers/common/cnxk/roc_npa_debug.c b/drivers/common/cnxk/roc_npa_debug.c index 173d32cd9b..9a16f481a8 100644 --- a/drivers/common/cnxk/roc_npa_debug.c +++ b/drivers/common/cnxk/roc_npa_debug.c @@ -89,8 +89,9 @@ npa_aura_dump(__io struct npa_aura_s *aura) int roc_npa_ctx_dump(void) { - struct npa_aq_enq_req *aq; + struct npa_cn20k_aq_enq_req *aq_cn20k; struct npa_aq_enq_rsp *rsp; + struct npa_aq_enq_req *aq; struct mbox *mbox; struct npa_lf *lf; uint32_t q; @@ -106,7 +107,12 @@ roc_npa_ctx_dump(void) if (plt_bitmap_get(lf->npa_bmp, q)) continue; - aq = mbox_alloc_msg_npa_aq_enq(mbox); + if (roc_model_is_cn20k()) { + aq_cn20k = mbox_alloc_msg_npa_cn20k_aq_enq(mbox); + aq = (struct npa_aq_enq_req *)aq_cn20k; + } else { + aq = mbox_alloc_msg_npa_aq_enq(mbox); + } if (aq == NULL) { rc = -ENOSPC; goto exit; @@ -129,7 +135,12 @@ roc_npa_ctx_dump(void) if (plt_bitmap_get(lf->npa_bmp, q)) continue; - aq = mbox_alloc_msg_npa_aq_enq(mbox); + if (roc_model_is_cn20k()) { + aq_cn20k = mbox_alloc_msg_npa_cn20k_aq_enq(mbox); + aq = (struct npa_aq_enq_req *)aq_cn20k; + } else { + aq = mbox_alloc_msg_npa_aq_enq(mbox); + } if (aq == NULL) { rc = -ENOSPC; goto exit; -- 2.34.1