From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id D3E43A0613 for ; Thu, 26 Sep 2019 14:37:32 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A43A21BE3D; Thu, 26 Sep 2019 14:37:03 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by dpdk.org (Postfix) with ESMTP id 0792B1B203 for ; Thu, 26 Sep 2019 14:36:56 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x8QCVH8k012885; Thu, 26 Sep 2019 05:36:56 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=pfpt0818; bh=XiwYtdFG9IGvlAKQye3SY/+GHnHBwYIniQ+YVCf42YM=; b=b+NobSoiHmgMQHiKJUHh9pv+FwLqQz+nzWZg9ilX4/fGG/V5j9cQ28Gp0DfbIMnymN/+ em4vmW0st2Aus0/dJnw6hncOC0BxpckR8VUZaX9MXEEJ1UHzE0KB/1AzMMX02GXvlExZ X8NS2ADmmoGCfg+WagjmKHUUZWPrv7arEoRfxfHnX1pp6XN6uuAw8igfAEsHfEi4ociB 8C+bDMPDhcOUg8QHdyMBPtLPnq+8AN/ggwr47QxLC4uXVTZRRLtLmedUWDsED6bahIsh B4BrILlA0XHkhMI0yXPHDcvoOy2IfUb6D7Djckwe+hscO/YpJsAkB8qU90z1cTfcyDnn Uw== Received: from sc-exch02.marvell.com ([199.233.58.182]) by mx0a-0016f401.pphosted.com with ESMTP id 2v8vdwg7xg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Thu, 26 Sep 2019 05:36:56 -0700 Received: from SC-EXCH02.marvell.com (10.93.176.82) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 26 Sep 2019 05:36:55 -0700 Received: from NAM04-CO1-obe.outbound.protection.outlook.com (104.47.45.55) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Thu, 26 Sep 2019 05:36:54 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lzUTlSXne7DgOG//gpJVweYMLN5hCPx5mD9fe2KUb9MYMReDRGFw3m17MtiAyWOIdKeVbXpQl8vbwKcJVbsteXm44RwYI7AYO7B3jdSlQJQODHbWIW1STu0VhYVaxN5XsC+1+XjDDIsAvHTeZTIap1aRhFHF92QMLJsaoQzyjYd/anvNgNEVVNqb2pZWHlFTdpH+FrszQdfRw3h+uPkFgKsaUs17LF9O4unDwsB5Zzm6sd/hauFI8/jeXgx5o7ohBjUWBtMz1FX8PrIx2jitf1GCeXwiKQ0X6u+pVFFtXnYy8Yf2HBifvc2+GUQ0gaM5s7FnE+0LxeWlkTaBMcjeMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XiwYtdFG9IGvlAKQye3SY/+GHnHBwYIniQ+YVCf42YM=; b=Q/FAVaZJDg1LBm0X/CvUqv0wUWQ7L8SzwdxZQU/CWr3YdnOlrl5chja1yudtL+T4OMjtiAL2aMZs9YS3kmGj5xz3mNl1EKTQJsqVF9DMklF1rkvsE1zKc0DTstQwDsyQIqWj1QU3xyEHXfXXp5o+6v0oFzpgYHJaLyQG79sy4OLOZuhCMf0O0/WA6IOJhiKVgV/0V49rZCKJpX0wvRXqB4RVj+m95D+esuGeDP+rziSpbcttJAhQUoKr5446z0o2NTXPSD5plgELhW3FrBr7fdK1m6VwjsouiLXC+vF/isVslwqRkmxWESxO4fQmY5dwuNGtcrKXz2cjl4zhyX2Gfw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector2-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=XiwYtdFG9IGvlAKQye3SY/+GHnHBwYIniQ+YVCf42YM=; b=S+zKzfjiJAs8Sf4XcG59POXsDqTdYdr/DIDQlla7mbcCvqihkBwYc1jvD0SN3u0CmfMG4Jats+p0G8pCAaBFT8DGR0ciphLjhvWtb/uIUmGWeTmBmmoqmeW0oMBP9CJ9tWNzMMfzl3UzWPZvQYTKEH1WekQNA8DDBh40kgRjdTQ= Received: from MN2PR18MB2797.namprd18.prod.outlook.com (20.179.22.16) by MN2PR18MB2766.namprd18.prod.outlook.com (20.178.255.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.17; Thu, 26 Sep 2019 12:36:53 +0000 Received: from MN2PR18MB2797.namprd18.prod.outlook.com ([fe80::2010:7134:bdcf:8ad9]) by MN2PR18MB2797.namprd18.prod.outlook.com ([fe80::2010:7134:bdcf:8ad9%7]) with mapi id 15.20.2284.028; Thu, 26 Sep 2019 12:36:53 +0000 From: Nagadheeraj Rottela To: "akhil.goyal@nxp.com" , "pablo.de.lara.guarch@intel.com" CC: Srikanth Jampala , "dev@dpdk.org" , Nagadheeraj Rottela Thread-Topic: [PATCH v5 4/8] crypto/nitrox: add hardware queue management functionality Thread-Index: AQHVdGcT3Iryh38B40SmEOvz6ji0QA== Date: Thu, 26 Sep 2019 12:36:53 +0000 Message-ID: <20190926123609.28417-5-rnagadheeraj@marvell.com> References: <20190716091016.4788-1-rnagadheeraj@marvell.com> <20190926123609.28417-1-rnagadheeraj@marvell.com> In-Reply-To: <20190926123609.28417-1-rnagadheeraj@marvell.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: BM1PR01CA0127.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:40::21) To MN2PR18MB2797.namprd18.prod.outlook.com (2603:10b6:208:a0::16) x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.13.6 x-originating-ip: [115.113.156.2] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: e5f28ecd-41cd-4b76-4917-08d7427e35cd x-ms-traffictypediagnostic: MN2PR18MB2766: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:127; x-forefront-prvs: 0172F0EF77 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(376002)(346002)(39860400002)(136003)(396003)(366004)(199004)(189003)(4326008)(66946007)(2501003)(66476007)(64756008)(66556008)(14444005)(256004)(3846002)(6116002)(66446008)(81156014)(8936002)(81166006)(8676002)(66066001)(7736002)(50226002)(305945005)(386003)(102836004)(52116002)(6506007)(55236004)(76176011)(26005)(11346002)(446003)(99286004)(186003)(14454004)(1076003)(478600001)(30864003)(36756003)(86362001)(54906003)(110136005)(2906002)(71200400001)(71190400001)(316002)(6486002)(5660300002)(476003)(6512007)(6436002)(486006)(107886003)(2616005)(25786009); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB2766; H:MN2PR18MB2797.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: marvell.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: MT2wSciwQ7QixodzvyXzqb0wt2g2Zxmm2h8IplUEgDeaj1VOVc4VkoRMgyG8UueeAO+haPJjyIYlpu0f9VFmaDzbYlEiNFXVFbPr5r2/Gox8UFcoCMHolbJO1bsZfFjq8FmwtZs699tZAD4nojgzYtCjha65OZE8exFxqSUGJmCc8lmq7DXbrfT+0nwSp+PDP2PLYlqOFWNsz0dyupmXNXOgTpOiDmvKa8fB4VGmGbKNa4i+KSxvHRUrb/b/9dNreojpgC/zWLXWR3Gra18lTNnKC/a0W4oZq4bdGG0lHVdwLcqQEZJZemukFplsbJWsLr6ZS3k7HIHTCQ4052ZioguBPqk602L6xS+GcLUyT+Y1X/ppwcsZApxCI+KuItCBLYfqC4R9iEuvYk4Y7LPRpF+oeQEY7JfyhkuC7izYEJU= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: e5f28ecd-41cd-4b76-4917-08d7427e35cd X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Sep 2019 12:36:53.6190 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: KEHs5I/Dtvzu6hZ9CkdmcMeDJAZ/fGKDwc9L+H+CH2qjSh6cQrK0qDxVD6DmJqrf2TpwK+SclEz7QTAhEaap+6/UAVChD0NQ7qlJAZDUrlY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB2766 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-09-26_06:2019-09-25,2019-09-26 signatures=0 Subject: [dpdk-dev] [PATCH v5 4/8] crypto/nitrox: add hardware queue management functionality X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Add hardware queue management code corresponding to queue pair setup and release functions. Signed-off-by: Nagadheeraj Rottela --- drivers/crypto/nitrox/nitrox_csr.h | 12 +++ drivers/crypto/nitrox/nitrox_hal.c | 151 +++++++++++++++++++++++++++++++++= ++++ drivers/crypto/nitrox/nitrox_hal.h | 128 +++++++++++++++++++++++++++++++ drivers/crypto/nitrox/nitrox_qp.c | 51 +++++++++++-- drivers/crypto/nitrox/nitrox_qp.h | 8 ++ 5 files changed, 345 insertions(+), 5 deletions(-) diff --git a/drivers/crypto/nitrox/nitrox_csr.h b/drivers/crypto/nitrox/nit= rox_csr.h index 879104515..8cd92e38b 100644 --- a/drivers/crypto/nitrox/nitrox_csr.h +++ b/drivers/crypto/nitrox/nitrox_csr.h @@ -9,6 +9,18 @@ #include =20 #define CSR_DELAY 30 +#define NITROX_CSR_ADDR(bar_addr, offset) (bar_addr + (offset)) + +/* NPS packet registers */ +#define NPS_PKT_IN_INSTR_CTLX(_i) (0x10060 + ((_i) * 0x40000)) +#define NPS_PKT_IN_INSTR_BADDRX(_i) (0x10068 + ((_i) * 0x40000)) +#define NPS_PKT_IN_INSTR_RSIZEX(_i) (0x10070 + ((_i) * 0x40000)) +#define NPS_PKT_IN_DONE_CNTSX(_i) (0x10080 + ((_i) * 0x40000)) +#define NPS_PKT_IN_INSTR_BAOFF_DBELLX(_i) (0x10078 + ((_i) * 0x40000)) +#define NPS_PKT_IN_INT_LEVELSX(_i) (0x10088 + ((_i) * 0x40000)) +#define NPS_PKT_SLC_CTLX(_i) (0x10000 + ((_i) * 0x40000)) +#define NPS_PKT_SLC_CNTSX(_i) (0x10008 + ((_i) * 0x40000)) +#define NPS_PKT_SLC_INT_LEVELSX(_i) (0x10010 + ((_i) * 0x40000)) =20 /* AQM Virtual Function Registers */ #define AQMQ_QSZX(_i) (0x20008 + ((_i)*0x40000)) diff --git a/drivers/crypto/nitrox/nitrox_hal.c b/drivers/crypto/nitrox/nit= rox_hal.c index ed1882016..433f3adb2 100644 --- a/drivers/crypto/nitrox/nitrox_hal.c +++ b/drivers/crypto/nitrox/nitrox_hal.c @@ -12,6 +12,157 @@ =20 #define MAX_VF_QUEUES 8 #define MAX_PF_QUEUES 64 +#define NITROX_TIMER_THOLD 0x3FFFFF +#define NITROX_COUNT_THOLD 0xFFFFFFFF + +void +nps_pkt_input_ring_disable(uint8_t *bar_addr, uint16_t ring) +{ + union nps_pkt_in_instr_ctl pkt_in_instr_ctl; + uint64_t reg_addr; + int max_retries =3D 5; + + reg_addr =3D NPS_PKT_IN_INSTR_CTLX(ring); + pkt_in_instr_ctl.u64 =3D nitrox_read_csr(bar_addr, reg_addr); + pkt_in_instr_ctl.s.enb =3D 0; + nitrox_write_csr(bar_addr, reg_addr, pkt_in_instr_ctl.u64); + rte_delay_us_block(100); + + /* wait for enable bit to be cleared */ + pkt_in_instr_ctl.u64 =3D nitrox_read_csr(bar_addr, reg_addr); + while (pkt_in_instr_ctl.s.enb && max_retries--) { + rte_delay_ms(10); + pkt_in_instr_ctl.u64 =3D nitrox_read_csr(bar_addr, reg_addr); + } +} + +void +nps_pkt_solicited_port_disable(uint8_t *bar_addr, uint16_t port) +{ + union nps_pkt_slc_ctl pkt_slc_ctl; + uint64_t reg_addr; + int max_retries =3D 5; + + /* clear enable bit */ + reg_addr =3D NPS_PKT_SLC_CTLX(port); + pkt_slc_ctl.u64 =3D nitrox_read_csr(bar_addr, reg_addr); + pkt_slc_ctl.s.enb =3D 0; + nitrox_write_csr(bar_addr, reg_addr, pkt_slc_ctl.u64); + rte_delay_us_block(100); + + pkt_slc_ctl.u64 =3D nitrox_read_csr(bar_addr, reg_addr); + while (pkt_slc_ctl.s.enb && max_retries--) { + rte_delay_ms(10); + pkt_slc_ctl.u64 =3D nitrox_read_csr(bar_addr, reg_addr); + } +} + +void +setup_nps_pkt_input_ring(uint8_t *bar_addr, uint16_t ring, uint32_t rsize, + phys_addr_t raddr) +{ + union nps_pkt_in_instr_ctl pkt_in_instr_ctl; + union nps_pkt_in_instr_rsize pkt_in_instr_rsize; + union nps_pkt_in_instr_baoff_dbell pkt_in_instr_baoff_dbell; + union nps_pkt_in_done_cnts pkt_in_done_cnts; + uint64_t base_addr, reg_addr; + int max_retries =3D 5; + + nps_pkt_input_ring_disable(bar_addr, ring); + + /* write base address */ + reg_addr =3D NPS_PKT_IN_INSTR_BADDRX(ring); + base_addr =3D raddr; + nitrox_write_csr(bar_addr, reg_addr, base_addr); + rte_delay_us_block(CSR_DELAY); + + /* write ring size */ + reg_addr =3D NPS_PKT_IN_INSTR_RSIZEX(ring); + pkt_in_instr_rsize.u64 =3D 0; + pkt_in_instr_rsize.s.rsize =3D rsize; + nitrox_write_csr(bar_addr, reg_addr, pkt_in_instr_rsize.u64); + rte_delay_us_block(CSR_DELAY); + + /* clear door bell */ + reg_addr =3D NPS_PKT_IN_INSTR_BAOFF_DBELLX(ring); + pkt_in_instr_baoff_dbell.u64 =3D 0; + pkt_in_instr_baoff_dbell.s.dbell =3D 0xFFFFFFFF; + nitrox_write_csr(bar_addr, reg_addr, pkt_in_instr_baoff_dbell.u64); + rte_delay_us_block(CSR_DELAY); + + /* clear done count */ + reg_addr =3D NPS_PKT_IN_DONE_CNTSX(ring); + pkt_in_done_cnts.u64 =3D nitrox_read_csr(bar_addr, reg_addr); + nitrox_write_csr(bar_addr, reg_addr, pkt_in_done_cnts.u64); + rte_delay_us_block(CSR_DELAY); + + /* Setup PKT IN RING Interrupt Threshold */ + reg_addr =3D NPS_PKT_IN_INT_LEVELSX(ring); + nitrox_write_csr(bar_addr, reg_addr, 0xFFFFFFFF); + rte_delay_us_block(CSR_DELAY); + + /* enable ring */ + reg_addr =3D NPS_PKT_IN_INSTR_CTLX(ring); + pkt_in_instr_ctl.u64 =3D 0; + pkt_in_instr_ctl.u64 =3D nitrox_read_csr(bar_addr, reg_addr); + pkt_in_instr_ctl.s.is64b =3D 1; + pkt_in_instr_ctl.s.enb =3D 1; + nitrox_write_csr(bar_addr, reg_addr, pkt_in_instr_ctl.u64); + rte_delay_us_block(100); + + pkt_in_instr_ctl.u64 =3D 0; + pkt_in_instr_ctl.u64 =3D nitrox_read_csr(bar_addr, reg_addr); + /* wait for ring to be enabled */ + while (!pkt_in_instr_ctl.s.enb && max_retries--) { + rte_delay_ms(10); + pkt_in_instr_ctl.u64 =3D nitrox_read_csr(bar_addr, reg_addr); + } +} + +void +setup_nps_pkt_solicit_output_port(uint8_t *bar_addr, uint16_t port) +{ + union nps_pkt_slc_ctl pkt_slc_ctl; + union nps_pkt_slc_cnts pkt_slc_cnts; + union nps_pkt_slc_int_levels pkt_slc_int_levels; + uint64_t reg_addr; + int max_retries =3D 5; + + nps_pkt_solicited_port_disable(bar_addr, port); + + /* clear pkt counts */ + reg_addr =3D NPS_PKT_SLC_CNTSX(port); + pkt_slc_cnts.u64 =3D nitrox_read_csr(bar_addr, reg_addr); + nitrox_write_csr(bar_addr, reg_addr, pkt_slc_cnts.u64); + rte_delay_us_block(CSR_DELAY); + + /* slc interrupt levels */ + reg_addr =3D NPS_PKT_SLC_INT_LEVELSX(port); + pkt_slc_int_levels.u64 =3D 0; + pkt_slc_int_levels.s.bmode =3D 0; + pkt_slc_int_levels.s.timet =3D NITROX_TIMER_THOLD; + + if (NITROX_COUNT_THOLD > 0) + pkt_slc_int_levels.s.cnt =3D NITROX_COUNT_THOLD - 1; + + nitrox_write_csr(bar_addr, reg_addr, pkt_slc_int_levels.u64); + rte_delay_us_block(CSR_DELAY); + + /* enable ring */ + reg_addr =3D NPS_PKT_SLC_CTLX(port); + pkt_slc_ctl.u64 =3D nitrox_read_csr(bar_addr, reg_addr); + pkt_slc_ctl.s.rh =3D 1; + pkt_slc_ctl.s.z =3D 1; + pkt_slc_ctl.s.enb =3D 1; + nitrox_write_csr(bar_addr, reg_addr, pkt_slc_ctl.u64); + rte_delay_us_block(100); + + pkt_slc_ctl.u64 =3D nitrox_read_csr(bar_addr, reg_addr); + while (!pkt_slc_ctl.s.enb && max_retries--) { + rte_delay_ms(10); + pkt_slc_ctl.u64 =3D nitrox_read_csr(bar_addr, reg_addr); + } +} =20 int vf_get_vf_config_mode(uint8_t *bar_addr) diff --git a/drivers/crypto/nitrox/nitrox_hal.h b/drivers/crypto/nitrox/nit= rox_hal.h index 6184211a5..dcfbd11d8 100644 --- a/drivers/crypto/nitrox/nitrox_hal.h +++ b/drivers/crypto/nitrox/nitrox_hal.h @@ -10,6 +10,129 @@ =20 #include "nitrox_csr.h" =20 +union nps_pkt_slc_cnts { + uint64_t u64; + struct { +#if RTE_BYTE_ORDER =3D=3D RTE_BIG_ENDIAN + uint64_t slc_int : 1; + uint64_t uns_int : 1; + uint64_t in_int : 1; + uint64_t mbox_int : 1; + uint64_t resend : 1; + uint64_t raz : 5; + uint64_t timer : 22; + uint64_t cnt : 32; +#else + uint64_t cnt : 32; + uint64_t timer : 22; + uint64_t raz : 5; + uint64_t resend : 1; + uint64_t mbox_int : 1; + uint64_t in_int : 1; + uint64_t uns_int : 1; + uint64_t slc_int : 1; +#endif + } s; +}; + +union nps_pkt_slc_int_levels { + uint64_t u64; + struct { +#if RTE_BYTE_ORDER =3D=3D RTE_BIG_ENDIAN + uint64_t bmode : 1; + uint64_t raz : 9; + uint64_t timet : 22; + uint64_t cnt : 32; +#else + uint64_t cnt : 32; + uint64_t timet : 22; + uint64_t raz : 9; + uint64_t bmode : 1; +#endif + } s; +}; + +union nps_pkt_slc_ctl { + uint64_t u64; + struct { +#if RTE_BYTE_ORDER =3D=3D RTE_BIG_ENDIAN + uint64_t raz : 61; + uint64_t rh : 1; + uint64_t z : 1; + uint64_t enb : 1; +#else + uint64_t enb : 1; + uint64_t z : 1; + uint64_t rh : 1; + uint64_t raz : 61; +#endif + } s; +}; + +union nps_pkt_in_instr_ctl { + uint64_t u64; + struct { +#if RTE_BYTE_ORDER =3D=3D RTE_BIG_ENDIAN + uint64_t raz : 62; + uint64_t is64b : 1; + uint64_t enb : 1; +#else + uint64_t enb : 1; + uint64_t is64b : 1; + uint64_t raz : 62; +#endif + } s; +}; + +union nps_pkt_in_instr_rsize { + uint64_t u64; + struct { +#if RTE_BYTE_ORDER =3D=3D RTE_BIG_ENDIAN + uint64_t raz : 32; + uint64_t rsize : 32; +#else + uint64_t rsize : 32; + uint64_t raz : 32; +#endif + } s; +}; + +union nps_pkt_in_instr_baoff_dbell { + uint64_t u64; + struct { +#if RTE_BYTE_ORDER =3D=3D RTE_BIG_ENDIAN + uint64_t aoff : 32; + uint64_t dbell : 32; +#else + uint64_t dbell : 32; + uint64_t aoff : 32; +#endif + } s; +}; + +union nps_pkt_in_done_cnts { + uint64_t u64; + struct { +#if RTE_BYTE_ORDER =3D=3D RTE_BIG_ENDIAN + uint64_t slc_int : 1; + uint64_t uns_int : 1; + uint64_t in_int : 1; + uint64_t mbox_int : 1; + uint64_t resend : 1; + uint64_t raz : 27; + uint64_t cnt : 32; +#else + uint64_t cnt : 32; + uint64_t raz : 27; + uint64_t resend : 1; + uint64_t mbox_int : 1; + uint64_t in_int : 1; + uint64_t uns_int : 1; + uint64_t slc_int : 1; +#endif + } s; +}; + union aqmq_qsz { uint64_t u64; struct { @@ -33,5 +156,10 @@ enum nitrox_vf_mode { =20 int vf_get_vf_config_mode(uint8_t *bar_addr); int vf_config_mode_to_nr_queues(enum nitrox_vf_mode vf_mode); +void setup_nps_pkt_input_ring(uint8_t *bar_addr, uint16_t ring, uint32_t r= size, + phys_addr_t raddr); +void setup_nps_pkt_solicit_output_port(uint8_t *bar_addr, uint16_t port); +void nps_pkt_input_ring_disable(uint8_t *bar_addr, uint16_t ring); +void nps_pkt_solicited_port_disable(uint8_t *bar_addr, uint16_t port); =20 #endif /* _NITROX_HAL_H_ */ diff --git a/drivers/crypto/nitrox/nitrox_qp.c b/drivers/crypto/nitrox/nitr= ox_qp.c index 9673bb4f3..5e85ccbd5 100644 --- a/drivers/crypto/nitrox/nitrox_qp.c +++ b/drivers/crypto/nitrox/nitrox_qp.c @@ -10,6 +10,38 @@ #include "nitrox_logs.h" =20 #define MAX_CMD_QLEN 16384 +#define CMDQ_PKT_IN_ALIGN 16 + +static int +nitrox_setup_cmdq(struct nitrox_qp *qp, uint8_t *bar_addr, + const char *dev_name, uint8_t instr_size, int socket_id) +{ + char mz_name[RTE_MEMZONE_NAMESIZE]; + const struct rte_memzone *mz; + size_t cmdq_size =3D qp->count * instr_size; + uint64_t offset; + + snprintf(mz_name, sizeof(mz_name), "%s_cmdq_%d", dev_name, qp->qno); + mz =3D rte_memzone_reserve_aligned(mz_name, cmdq_size, socket_id, + RTE_MEMZONE_SIZE_HINT_ONLY | + RTE_MEMZONE_256MB, + CMDQ_PKT_IN_ALIGN); + if (!mz) { + NITROX_LOG(ERR, "cmdq memzone reserve failed for %s queue\n", + mz_name); + return -ENOMEM; + } + + qp->cmdq.mz =3D mz; + offset =3D NPS_PKT_IN_INSTR_BAOFF_DBELLX(qp->qno); + qp->cmdq.dbell_csr_addr =3D NITROX_CSR_ADDR(bar_addr, offset); + qp->cmdq.ring =3D mz->addr; + qp->cmdq.instr_size =3D instr_size; + setup_nps_pkt_input_ring(bar_addr, qp->qno, qp->count, mz->iova); + setup_nps_pkt_solicit_output_port(bar_addr, qp->qno); + + return 0; +} =20 static int nitrox_setup_ridq(struct nitrox_qp *qp, int socket_id) @@ -27,6 +59,14 @@ nitrox_setup_ridq(struct nitrox_qp *qp, int socket_id) return 0; } =20 +static int +nitrox_release_cmdq(struct nitrox_qp *qp, uint8_t *bar_addr) +{ + nps_pkt_solicited_port_disable(bar_addr, qp->qno); + nps_pkt_input_ring_disable(bar_addr, qp->qno); + return rte_memzone_free(qp->cmdq.mz); +} + int nitrox_qp_setup(struct nitrox_qp *qp, uint8_t *bar_addr, const char *dev_n= ame, uint32_t nb_descriptors, uint8_t instr_size, int socket_id) @@ -34,8 +74,6 @@ nitrox_qp_setup(struct nitrox_qp *qp, uint8_t *bar_addr, = const char *dev_name, int err; uint32_t count; =20 - RTE_SET_USED(bar_addr); - RTE_SET_USED(instr_size); count =3D rte_align32pow2(nb_descriptors); if (count > MAX_CMD_QLEN) { NITROX_LOG(ERR, "%s: Number of descriptors too big %d," @@ -48,6 +86,10 @@ nitrox_qp_setup(struct nitrox_qp *qp, uint8_t *bar_addr,= const char *dev_name, qp->count =3D count; qp->head =3D qp->tail =3D 0; rte_atomic16_init(&qp->pending_count); + err =3D nitrox_setup_cmdq(qp, bar_addr, dev_name, instr_size, socket_id); + if (err) + return err; + err =3D nitrox_setup_ridq(qp, socket_id); if (err) goto ridq_err; @@ -55,8 +97,8 @@ nitrox_qp_setup(struct nitrox_qp *qp, uint8_t *bar_addr, = const char *dev_name, return 0; =20 ridq_err: + nitrox_release_cmdq(qp, bar_addr); return err; - } =20 static void @@ -68,7 +110,6 @@ nitrox_release_ridq(struct nitrox_qp *qp) int nitrox_qp_release(struct nitrox_qp *qp, uint8_t *bar_addr) { - RTE_SET_USED(bar_addr); nitrox_release_ridq(qp); - return 0; + return nitrox_release_cmdq(qp, bar_addr); } diff --git a/drivers/crypto/nitrox/nitrox_qp.h b/drivers/crypto/nitrox/nitr= ox_qp.h index cf0102ff9..0244c4dbf 100644 --- a/drivers/crypto/nitrox/nitrox_qp.h +++ b/drivers/crypto/nitrox/nitrox_qp.h @@ -11,11 +11,19 @@ =20 struct nitrox_softreq; =20 +struct command_queue { + const struct rte_memzone *mz; + uint8_t *dbell_csr_addr; + uint8_t *ring; + uint8_t instr_size; +}; + struct rid { struct nitrox_softreq *sr; }; =20 struct nitrox_qp { + struct command_queue cmdq; struct rid *ridq; uint32_t count; uint32_t head; --=20 2.13.6