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 8DB01A2EDB for ; Tue, 1 Oct 2019 08:42:07 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6CAE21BE8B; Tue, 1 Oct 2019 08:41:33 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by dpdk.org (Postfix) with ESMTP id A7D6E1BE3D for ; Tue, 1 Oct 2019 08:41:31 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x916ei2e024077; Mon, 30 Sep 2019 23:41:31 -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=fgLSdambEIRZmN/Xp8tzbP8KMe0bxkLYt0uLBqVR0fSlG4DxSAAXHi9yH7UEHUyRQe5S AhYMk9OQd53fDpYUe+p4y+wRxAB0ZVHo8nGgv5TR+q4h1TgFGqTYH7ZkNhi6D3m/I/tE Z50uCK5R+EO8jplP4aVXk36DlMH+aDM2fml/ZG5EO4rDcQeg7Oayer8hdoKU/2hB3p3I +Uwq04PBHDDR/MghbnZh/mNSEyCEp1WBSFLQ2yl8xwHv36lJTTiZXqY18nMGsMgpytt+ 4uPe9xf4sy5luE/NdzZtEokJZ4WIR3y/O7uxSr3xJ+qm49lgr3gS1NA+iSa+iMac8sLS BA== Received: from sc-exch03.marvell.com ([199.233.58.183]) by mx0b-0016f401.pphosted.com with ESMTP id 2va71mh7vg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Mon, 30 Sep 2019 23:41:30 -0700 Received: from SC-EXCH02.marvell.com (10.93.176.82) by SC-EXCH03.marvell.com (10.93.176.83) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Mon, 30 Sep 2019 23:41:29 -0700 Received: from NAM04-SN1-obe.outbound.protection.outlook.com (104.47.44.54) by SC-EXCH02.marvell.com (10.93.176.82) with Microsoft SMTP Server (TLS) id 15.0.1367.3 via Frontend Transport; Mon, 30 Sep 2019 23:41:28 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bPy7V37NCaiSuE0dBOIF6GmVsz6buTvvh6kYugIrjM1YJGKxffAz4dsAlUCUX0MFoJ24aOWaXL3fb/PaKDwkUwXP1/pquVUAgbv4FZyq9VZPtnbuoeBoNVGk07CjbMFNhwg+FamFZ0IKInohnboDsWWahQusH6OXcnKtElT9FuL6NpRHbQY2TkYhOTpY1IEqaZU8Po7JqQdPuMQDBE/moRNDqrG/WWm1T6Jxca+9jsQpfDa9oYS48SPuapVxJjHhTOmunQQ+bdnxaIxVu1+a/AemQs3rgH+NMnWlK57ZbMHhLuTG2D6p82IVZr9laQ/7wenYmH5sSFmogUnga4avIg== 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=FSxxTKGhgAzxcWb4UdXzpsqLIkrWF/JqyXJ1f3CnkV2GfEmRrE39mVFbukKUM89/oAvcTIyapYMWGUhJQv+nKVj/vJsKGdQsp3JQCyehGrqN4J9wRrlJ/x5+xJDF8kvKokQyyhVuT+Y33/EbhEOkDN9yvVE39n1IJ6IqjTQ68MlEqCnFoLGH4Q0gDVCt/liMW7SnSxSvOyXah+Y0nQgpKzB1z/cdFGVe49mUlKNOUasCQQLbEs3T6xmwKNqjfoJM0if4tueGjW6GHepyha7pklFpvyiRtMClzBxzoIgTTkQUVQZeUI8+8i5jyqnZubCq18EdTN+ucb4+QVgttk31ww== 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=s5QI99Eppoem4dAMtProFlpYWVFNqtU32FZgYM6vQfVULkeOcrwWUc+Tor2DVlFdkeaI9LsCnU6e7S7P4s5CIuORt3qQo6aygEpkmybSC/abHK6iO3z0/7TIh30+HCQp8PRCTWd1ACuLKK2znGijuSrDV3Whpiuj1VHAA4hS4mI= Received: from MN2PR18MB2797.namprd18.prod.outlook.com (20.179.22.16) by MN2PR18MB3375.namprd18.prod.outlook.com (10.255.238.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.15; Tue, 1 Oct 2019 06:41:27 +0000 Received: from MN2PR18MB2797.namprd18.prod.outlook.com ([fe80::259c:a73e:a83:ccfe]) by MN2PR18MB2797.namprd18.prod.outlook.com ([fe80::259c:a73e:a83:ccfe%4]) with mapi id 15.20.2305.017; Tue, 1 Oct 2019 06:41:27 +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 v7 4/8] crypto/nitrox: add hardware queue management functionality Thread-Index: AQHVeCNAYlmtZsoCnEiFVHBGG0lQiA== Date: Tue, 1 Oct 2019 06:41:27 +0000 Message-ID: <20191001064048.5624-5-rnagadheeraj@marvell.com> References: <20190716091016.4788-1-rnagadheeraj@marvell.com> <20191001064048.5624-1-rnagadheeraj@marvell.com> In-Reply-To: <20191001064048.5624-1-rnagadheeraj@marvell.com> Accept-Language: en-IN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PN1PR0101CA0050.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:d::12) 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: b68856bb-ca90-413a-2a02-08d7463a6283 x-ms-traffictypediagnostic: MN2PR18MB3375: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:127; x-forefront-prvs: 0177904E6B x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(4636009)(366004)(396003)(39850400004)(346002)(136003)(376002)(199004)(189003)(66946007)(76176011)(6512007)(66556008)(476003)(81166006)(66476007)(478600001)(446003)(14444005)(52116002)(256004)(99286004)(486006)(81156014)(8936002)(305945005)(2616005)(64756008)(5660300002)(4326008)(66066001)(316002)(11346002)(6436002)(25786009)(2906002)(386003)(71200400001)(71190400001)(14454004)(107886003)(6486002)(55236004)(102836004)(110136005)(54906003)(8676002)(2501003)(186003)(66446008)(6116002)(3846002)(50226002)(86362001)(30864003)(26005)(36756003)(1076003)(7736002)(6506007); DIR:OUT; SFP:1101; SCL:1; SRVR:MN2PR18MB3375; 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: CEwhrqKQMa73AL4XvtZrCCvFgrgX9e/cuKmLLCGnoGWqn3asPE/7XnSppyLN5XCt77kE4UF/vJ8kRpMqRcyR3O/Tcn5YUR7HiyT+egQCbk7QY/6LlkLq7YkYzIlRxgzBeLTYN2xmB1n2sWFIPKksowSpORn8uYab+ESv7EgOOFrmCmO3NjwdlM9j8LVptfp2Lf0bcDJ/CGK0s44RlF1DLe7WqLLIuV1LNo7iX59glBfxd8Pa1WI5CuvDcF2aMr64n6sXRsNRDRgnheloaZtILYi80T9M2SIZ6Ds4o8mTGFD909WabhShawSf/0La3xO4N4Qbx5GtRb+8Eeenzfqv0iRkEU/+YD+luN7iA3mckwSo46FvXmjTHo3sXf6PaxKcU/cQaS5yu/5Zg6fUSYjYnkU5aA+WVP0IdMSbktNL1WQ= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-Network-Message-Id: b68856bb-ca90-413a-2a02-08d7463a6283 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Oct 2019 06:41:27.3473 (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: NpUsDneemiIjpcwfWsu7yYNOLE64IIj8g7JS2Mv1LQ1JW84xQzNC0OgHgqjcbiuP8wYFgn6NSDG5PQuLuNWObJeMqcywr+/aEbnItKaNFXY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR18MB3375 X-OriginatorOrg: marvell.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-01_03:2019-09-30,2019-10-01 signatures=0 Subject: [dpdk-dev] [PATCH v7 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