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 EADD6423C1 for ; Fri, 13 Jan 2023 13:00:28 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E61D942DEF; Fri, 13 Jan 2023 13:00:28 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2042.outbound.protection.outlook.com [40.107.244.42]) by mails.dpdk.org (Postfix) with ESMTP id A2EFF40E03; Fri, 13 Jan 2023 13:00:25 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VZmfnk0ZwifhCNgXPqYMGBXmLBem8KnGPQuJfGXbdc72ygn2qvVs2QTp74qSHIfmCJO2m7qLdVQoChUULEE8jJFwXmqkR5/I2zqVcoug0gkJhOXmC1WWZ2D68QTmMn7e4OhSQ+n5PS9ahF/hrW6t2RNqjVw3QRZg3sHOS4i18R9Ex7ayI+jYTHXfcTuvneMs/ta/IaNuJDh1iMDzR0bySPnXuMFsS9UfuWtGtihuF7AzHw8wy9j/rb8We1sQQtPBJ+Jx2zYm++XpaZbJsEuhdaJyVeD85aUB5gVGqj7P85KK748bSgbTJA3f5HSCc2y/6Ub82tNhe2aLU0o8zcWxcw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=EqsqNf/MnFk3TpR91EAvZMD+hG1z9KqQZQZfV0tVXhg=; b=GuR9/gEFv2WiVmJSQQJ02L8Wc6+pcfVZMtBGk/rUFmN97oMabZyXFkNQVOJVWTzQsajHSmxINBaU83vlezP9jZydQqf/CTVLCio1FMVwVoBYnQR9Cxp3+IMnCXM+5xK/L1e+CGLCYdh+m/Niamz/5zbhA08cIDe4bgWHrt1Z4bkVVjcKxEyO6WiG7B2dciCv1LhfZv4qMJnavIcoC3n9eYZ8eRBeYEfmVy+PnIrIfApuWyZ6xLbkyTBfcKP/kj8LrmVUC6yxMMoz/0dyJkHmw0AYKcUjONitX8frKFgTlpeywakQYeLSrg6os8iv1GbXUjgA5v86TXC2gJhf2dhAYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=EqsqNf/MnFk3TpR91EAvZMD+hG1z9KqQZQZfV0tVXhg=; b=f08Ui6ZCBv/IEqPsDovWRIsGvTrHn0021u3Z3unCumh3iKZp0MFf4iXnkq8rnhlVWVomHZt+33O6jqPXdml3odrLOcCaEpZMw8DI18OYedqsTl3OvG+RJQFae0I8mRVLfeKZl/FNJca0ltURBQ/Kd1eK5+CMHbzjWeSDcpWIuqk= Received: from PH7PR12MB6694.namprd12.prod.outlook.com (2603:10b6:510:1b1::8) by DM4PR12MB6134.namprd12.prod.outlook.com (2603:10b6:8:ad::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5986.18; Fri, 13 Jan 2023 12:00:23 +0000 Received: from PH7PR12MB6694.namprd12.prod.outlook.com ([fe80::e09f:be08:39fb:4490]) by PH7PR12MB6694.namprd12.prod.outlook.com ([fe80::e09f:be08:39fb:4490%6]) with mapi id 15.20.5986.018; Fri, 13 Jan 2023 12:00:23 +0000 From: "Uttarwar, Sunil Prakashrao" To: David Marchand , "dev@dpdk.org" CC: "gakhil@marvell.com" , "stable@dpdk.org" , "Somalapuram, Amaranath" Subject: RE: [PATCH v2 3/4] crypto/ccp: fix IOVA handling Thread-Topic: [PATCH v2 3/4] crypto/ccp: fix IOVA handling Thread-Index: AQHY19b0vDFv7T9bVE2FcOZrVxYcV66c3Xxg Date: Fri, 13 Jan 2023 12:00:23 +0000 Message-ID: References: <20220909150411.3702860-1-david.marchand@redhat.com> <20221004095132.198777-1-david.marchand@redhat.com> <20221004095132.198777-4-david.marchand@redhat.com> In-Reply-To: <20221004095132.198777-4-david.marchand@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_Enabled=true; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_SetDate=2023-01-13T12:00:20Z; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_Method=Privileged; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_Name=Public-AIP 2.0; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_ActionId=08e6e552-36e3-4948-b997-67cb94ad5e70; MSIP_Label_d4243a53-6221-4f75-8154-e4b33a5707a1_ContentBits=1 authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: PH7PR12MB6694:EE_|DM4PR12MB6134:EE_ x-ms-office365-filtering-correlation-id: dcd1a4bf-24dd-4301-0425-08daf55dc030 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: wqQlLzlgkzA689a10T48+zBRII40Cu33bIfl/srf6BrwytBONN1Gy9LxYTUEBrJ1S7GU48c+xEXFaSEMDA7aRRlP6FLQyDOoZnQprclZ9jvmbKoZS7EAy4043MjYgwhECeV6Y1EOD4eFTkQgZQsjNNOGMwuH31da6HqB2+5WaEO0sPUbq3RiBMWBXv6qF6UPJQcQuh7wWBLrDyxQseIIagLbMIv2FWXEOmK93S3F/WCrZimWl0gGk2+3TJeB8IvzYm/Hhz8KDG1dKMqsSQNyYiMUoqQJcMaLVQ/K0rIVWVkM6ysiIM/7WjIPRk0z8+6bOTySN72qde7Fbk0n7aJvFUQmmqVbtsBBcbMfWbZRKIuNivZUH/F5MQSNv5MD/gpCUCz0Lyg1xvqjpbV8pg6EVEfLwZHfG41Db4KIIN93dkhD2ECY6IiK5jojEL/QTS+RX4nCN9brx2dU89/xc1/AGHfkNnAb9aw+6B6HFa6UMmaZOKrFljajfuwAQwexVFfJ3NFNyA01lPWB/3HLAcmmN6EzudZTNsieo0JdPZ5O3Ob/3eqSrUQr5xiD4HgQDb3PFWewGrbwiSEsQbu2TgcJqpNhZNdVgc9w2Oc92v3wQaBNbatPGZ2txYKsAwlyYq+7fbAG1+7oBtc+zjB/JEbUSkZkCMhI5KVfjI+DlaGO7OXqmlH4bX0J+NbSRUMeASwk x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PH7PR12MB6694.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(366004)(376002)(136003)(39860400002)(346002)(396003)(451199015)(86362001)(33656002)(30864003)(7696005)(316002)(26005)(71200400001)(9686003)(186003)(478600001)(5660300002)(83380400001)(64756008)(41300700001)(54906003)(66476007)(66446008)(4326008)(66556008)(110136005)(66946007)(76116006)(52536014)(8936002)(38070700005)(8676002)(55016003)(53546011)(6506007)(38100700002)(122000001)(2906002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Q6kalPZ7deUk2e6jfWaZcEtPjY/U5y5JWHKNZI1YRN0c7I7CfssFS/QpMLij?= =?us-ascii?Q?mXi8c97n6aNwt0rhoDxtebWDFdmKZzvKWiwHpXUO7tZ/PFT9nQM2fRZsvFS9?= =?us-ascii?Q?k7BmbMjtWH70K3ZWgElep4zVs/EoHxjLPMoqwWhoy+1/60kiMWTcxoOXUKwl?= =?us-ascii?Q?73Spy6TP47V3pCdPVPcoawvYeG4Jmb9R1KB38fOOXTUHe86D1nazRJ9P/b8R?= =?us-ascii?Q?uEnZMvE+TsCVDU6e0HFlg8ksJjrpXPoGqoegmwK/YU1Eoq8bnePBdndvzRtx?= =?us-ascii?Q?vpEIEElpqVR5HGojJeosT8Jq0rvX+kAYcmdA/xym4Xm16nuEJXJ6ZC/hPg4c?= =?us-ascii?Q?Lryz1PRIZw6Yy9H0Cd5GJb+TFW/iAuBVlQ9+TgiPhh0Cjwwsk80eVYhysQFF?= =?us-ascii?Q?7Y8qrL4dI7g1uv5ACN6xbQGWwMIyOwE44uJR7mA9Dah6nOSAg3kjDKK9HowN?= =?us-ascii?Q?CD8ImE1diYx4F4XznRwH+DzF7VPKkfbac+KzJsu566Xdqdy2KdmcVbr+pi94?= =?us-ascii?Q?DRBH5vG2ABudurWBRH7WX0oXcvY7lHvpTyujIHSNIzRf/Q7EbKjdtLLKMR7c?= =?us-ascii?Q?apGCNV9IWthjkzgw4Ylnu1kEFvXJCX42BBO6nRG87poVDOjrwTfHXoTkbWLp?= =?us-ascii?Q?17yUVjqYSNqOouVPJ4QF3+AykBD8/WgWNexz84CZAuqgCYI5/DjXJ3qfTwFk?= =?us-ascii?Q?p5P+l4cQM9EoSftFehZz7WtaRVFaSbiEpoSco3onGx7ERJpFL5vbDQDoEitY?= =?us-ascii?Q?K900hSxkD4H0Hq0ggvFBl42y0YdXsS3mNG7zoZe0tF6Mx/IMVOIcK84e2kS2?= =?us-ascii?Q?7TZ1NeOrljZ5r/Uz2bOTPPAO/MwZyZSsnGDqlr50rkhmrQcRjzHEhI5R9fqY?= =?us-ascii?Q?RO+D8IxPDPv3pAmj9Nt+eHDDusm12On4tN2UaOsnKziaBBgRbUIE04GB5Nfl?= =?us-ascii?Q?5eqEo66908ru7HuHbzats6KyZEYswsUQvgNUWgurskYEBe9zf+5/r5vTaOvd?= =?us-ascii?Q?ZbDanvB2SzANLnkQEwzR8zZmDXsJDaXwcOcYPww6Iej0L119X3+1Og7mL62E?= =?us-ascii?Q?+4u4FqRA5wtExR/huPj1uZ5gLcXOBdBTgCCUKO3kWyPbv5xPFocd5TB/PYVL?= =?us-ascii?Q?K7j4BNoufllD5RuomxQ7YfcXLjyjNCQgpISq95csjzrXE+8a1wHfQedOFa/X?= =?us-ascii?Q?jfa8Ois32xDl3vXnJ5dblsccbFVkkFm8JAOByPwliQNN+V0U5c6tg+K6W5a0?= =?us-ascii?Q?IqKZLczYNlBTQTOjpsK6jeyABhdrDQ3am2VAXzvrXMgyktGs3Ki5b074y/p0?= =?us-ascii?Q?DSp6sn2rhiEn/SoGzstZHpR92MDo+Wg9S838UA4DmDSXRWmdo+IujrE62i2I?= =?us-ascii?Q?vpitBYWCyF0at76rhiPM9R8lEzAYgrL8DAStqESh+tk8GA3FnK/r5eMjK6n3?= =?us-ascii?Q?eGYBBWX5Yn9xo3BtFgB1n6xclR3VgHwJnsz8ArZWan15XqcJMQ/S7JOeRlgY?= =?us-ascii?Q?tljPEc0JJicW5DmWLYLoXCMr6s8ZZORNBLu6g3zxTuQzcIIwWSbkS2qoXBc5?= =?us-ascii?Q?19hAzxYBLOxIQUSZffQ=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: PH7PR12MB6694.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: dcd1a4bf-24dd-4301-0425-08daf55dc030 X-MS-Exchange-CrossTenant-originalarrivaltime: 13 Jan 2023 12:00:23.0857 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: hfEkSF0ypc7S6YOkyAgKOYLS/xQsIT6Z5FFLETYOfd9WIK1VyI7iJMxmVXNIgqWFGrkbL7AVe5sX04iWAP7L/Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6134 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org [Public] Acked-by: Sunil Uttarwar -----Original Message----- From: David Marchand =20 Sent: Tuesday, October 4, 2022 3:22 PM To: dev@dpdk.org Cc: gakhil@marvell.com; Uttarwar, Sunil Prakashrao ; stable@dpdk.org; Somalapuram, Amaranath Subject: [PATCH v2 3/4] crypto/ccp: fix IOVA handling Caution: This message originated from an External Source. Use proper cautio= n when opening attachments, clicking links, or responding. Using IOVA or physical addresses is something that the user (via --iova-mode=3D) or the bus code decides. The crypto/ccp PCI driver should only use rte_mem_virt2iova. It should not try to decide what to use solely based on the kmod the PCI de= vice is bound to. While at it, the global variable sha_ctx looks unsafe and unneeded. Remove it. Fixes: 09a0fd736a08 ("crypto/ccp: enable IOMMU") Cc: stable@dpdk.org Signed-off-by: David Marchand --- drivers/crypto/ccp/ccp_crypto.c | 105 ++++++------------------------- drivers/crypto/ccp/ccp_dev.c | 9 +-- drivers/crypto/ccp/ccp_pci.c | 34 ---------- drivers/crypto/ccp/ccp_pci.h | 3 - drivers/crypto/ccp/rte_ccp_pmd.c | 3 - 5 files changed, 19 insertions(+), 135 deletions(-) diff --git a/drivers/crypto/ccp/ccp_crypto.c b/drivers/crypto/ccp/ccp_crypt= o.c index 4bab18323b..351d8ac63e 100644 --- a/drivers/crypto/ccp/ccp_crypto.c +++ b/drivers/crypto/ccp/ccp_crypto.c @@ -33,8 +33,6 @@ #include #include -extern int iommu_mode; -void *sha_ctx; /* SHA initial context values */ uint32_t ccp_sha1_init[SHA_COMMON_DIGEST_SIZE / sizeof(uint32_t)] =3D { SHA1_H4, SHA1_H3, @@ -748,13 +746,8 @@ ccp_configure_session_cipher(struct ccp_session *sess, CCP_LOG_ERR("Invalid CCP Engine"); return -ENOTSUP; } - if (iommu_mode =3D=3D 2) { - sess->cipher.nonce_phys =3D rte_mem_virt2iova(sess->cipher.= nonce); - sess->cipher.key_phys =3D rte_mem_virt2iova(sess->cipher.ke= y_ccp); - } else { - sess->cipher.nonce_phys =3D rte_mem_virt2phy(sess->cipher.n= once); - sess->cipher.key_phys =3D rte_mem_virt2phy(sess->cipher.key= _ccp); - } + sess->cipher.nonce_phys =3D rte_mem_virt2iova(sess->cipher.nonce); + sess->cipher.key_phys =3D rte_mem_virt2iova(sess->cipher.key_ccp); return 0; } @@ -793,7 +786,6 @@ ccp_configure_session_auth(struct ccp_session *sess, sess->auth.ctx =3D (void *)ccp_sha1_init; sess->auth.ctx_len =3D CCP_SB_BYTES; sess->auth.offset =3D CCP_SB_BYTES - SHA1_DIGEST_SIZE; - rte_memcpy(sha_ctx, sess->auth.ctx, SHA_COMMON_DIGEST_SIZE)= ; break; case RTE_CRYPTO_AUTH_SHA1_HMAC: if (sess->auth_opt) { @@ -832,7 +824,6 @@ ccp_configure_session_auth(struct ccp_session *sess, sess->auth.ctx =3D (void *)ccp_sha224_init; sess->auth.ctx_len =3D CCP_SB_BYTES; sess->auth.offset =3D CCP_SB_BYTES - SHA224_DIGEST_SIZE; - rte_memcpy(sha_ctx, sess->auth.ctx, SHA256_DIGEST_SIZE); break; case RTE_CRYPTO_AUTH_SHA224_HMAC: if (sess->auth_opt) { @@ -895,7 +886,6 @@ ccp_configure_session_auth(struct ccp_session *sess, sess->auth.ctx =3D (void *)ccp_sha256_init; sess->auth.ctx_len =3D CCP_SB_BYTES; sess->auth.offset =3D CCP_SB_BYTES - SHA256_DIGEST_SIZE; - rte_memcpy(sha_ctx, sess->auth.ctx, SHA256_DIGEST_SIZE); break; case RTE_CRYPTO_AUTH_SHA256_HMAC: if (sess->auth_opt) { @@ -958,7 +948,6 @@ ccp_configure_session_auth(struct ccp_session *sess, sess->auth.ctx =3D (void *)ccp_sha384_init; sess->auth.ctx_len =3D CCP_SB_BYTES << 1; sess->auth.offset =3D (CCP_SB_BYTES << 1) - SHA384_DIGEST_S= IZE; - rte_memcpy(sha_ctx, sess->auth.ctx, SHA512_DIGEST_SIZE); break; case RTE_CRYPTO_AUTH_SHA384_HMAC: if (sess->auth_opt) { @@ -1023,7 +1012,6 @@ ccp_configure_session_auth(struct ccp_session *sess, sess->auth.ctx =3D (void *)ccp_sha512_init; sess->auth.ctx_len =3D CCP_SB_BYTES << 1; sess->auth.offset =3D (CCP_SB_BYTES << 1) - SHA512_DIGEST_S= IZE; - rte_memcpy(sha_ctx, sess->auth.ctx, SHA512_DIGEST_SIZE); break; case RTE_CRYPTO_AUTH_SHA512_HMAC: if (sess->auth_opt) { @@ -1173,13 +1161,8 @@ ccp_configure_session_aead(struct ccp_session *sess, CCP_LOG_ERR("Unsupported aead algo"); return -ENOTSUP; } - if (iommu_mode =3D=3D 2) { - sess->cipher.nonce_phys =3D rte_mem_virt2iova(sess->cipher.= nonce); - sess->cipher.key_phys =3D rte_mem_virt2iova(sess->cipher.ke= y_ccp); - } else { - sess->cipher.nonce_phys =3D rte_mem_virt2phy(sess->cipher.n= once); - sess->cipher.key_phys =3D rte_mem_virt2phy(sess->cipher.key= _ccp); - } + sess->cipher.nonce_phys =3D rte_mem_virt2iova(sess->cipher.nonce); + sess->cipher.key_phys =3D rte_mem_virt2iova(sess->cipher.key_ccp); return 0; } @@ -1594,14 +1577,8 @@ ccp_perform_hmac(struct rte_crypto_op *op, op->sym->auth.data.offset); append_ptr =3D (void *)rte_pktmbuf_append(op->sym->m_src, session->auth.ctx_len); - if (iommu_mode =3D=3D 2) { - dest_addr =3D (phys_addr_t)rte_mem_virt2iova(append_ptr); - pst.src_addr =3D (phys_addr_t)rte_mem_virt2iova((void *)add= r); - } else { - dest_addr =3D (phys_addr_t)rte_mem_virt2phy(append_ptr); - pst.src_addr =3D (phys_addr_t)rte_mem_virt2phy((void *)addr= ); - } - dest_addr_t =3D dest_addr; + dest_addr_t =3D dest_addr =3D (phys_addr_t)rte_mem_virt2iova(append= _ptr); + pst.src_addr =3D (phys_addr_t)rte_mem_virt2iova((void *)addr); /** Load PHash1 to LSB*/ pst.dest_addr =3D (phys_addr_t)(cmd_q->sb_sha * CCP_SB_BYTES); @@ -= 1683,10 +1660,7 @@ ccp_perform_hmac(struct rte_crypto_op *op, /** Load PHash2 to LSB*/ addr +=3D session->auth.ctx_len; - if (iommu_mode =3D=3D 2) - pst.src_addr =3D (phys_addr_t)rte_mem_virt2iova((void *)add= r); - else - pst.src_addr =3D (phys_addr_t)rte_mem_virt2phy((void *)addr= ); + pst.src_addr =3D (phys_addr_t)rte_mem_virt2iova((void *)addr); pst.dest_addr =3D (phys_addr_t)(cmd_q->sb_sha * CCP_SB_BYTES); pst.len =3D session->auth.ctx_len; pst.dir =3D 1; @@ -1774,14 +1748,8 @@ ccp_perform_sha(struct rte_crypto_op *op, op->sym->auth.data.offset); append_ptr =3D (void *)rte_pktmbuf_append(op->sym->m_src, session->auth.ctx_len); - if (iommu_mode =3D=3D 2) { - dest_addr =3D (phys_addr_t)rte_mem_virt2iova(append_ptr); - pst.src_addr =3D (phys_addr_t)sha_ctx; - } else { - dest_addr =3D (phys_addr_t)rte_mem_virt2phy(append_ptr); - pst.src_addr =3D (phys_addr_t)rte_mem_virt2phy((void *) - session->auth.ctx); - } + pst.src_addr =3D (phys_addr_t)rte_mem_virt2iova((void *)session->au= th.ctx); + dest_addr =3D (phys_addr_t)rte_mem_virt2iova(append_ptr); /** Passthru sha context*/ @@ -1871,15 +1839,8 @@ ccp_perform_sha3_hmac(struct rte_crypto_op *op, CCP_LOG_ERR("CCP MBUF append failed\n"); return -1; } - if (iommu_mode =3D=3D 2) { - dest_addr =3D (phys_addr_t)rte_mem_virt2iova((void *)append= _ptr); - ctx_paddr =3D (phys_addr_t)rte_mem_virt2iova( - session->auth.pre_compute); - } else { - dest_addr =3D (phys_addr_t)rte_mem_virt2phy((void *)append_= ptr); - ctx_paddr =3D (phys_addr_t)rte_mem_virt2phy( - session->auth.pre_compute); - } + dest_addr =3D (phys_addr_t)rte_mem_virt2iova((void *)append_ptr); + ctx_paddr =3D=20 + (phys_addr_t)rte_mem_virt2iova(session->auth.pre_compute); dest_addr_t =3D dest_addr + (session->auth.ctx_len / 2); desc =3D &cmd_q->qbase_desc[cmd_q->qidx]; memset(desc, 0, Q_DESC_SIZE); @@ -2017,13 +1978,8 @@ ccp_perform_sha3(struct rte_crypto_op *op, CCP_LOG_ERR("CCP MBUF append failed\n"); return -1; } - if (iommu_mode =3D=3D 2) { - dest_addr =3D (phys_addr_t)rte_mem_virt2iova((void *)append= _ptr); - ctx_paddr =3D (phys_addr_t)rte_mem_virt2iova((void *)ctx_ad= dr); - } else { - dest_addr =3D (phys_addr_t)rte_mem_virt2phy((void *)append_= ptr); - ctx_paddr =3D (phys_addr_t)rte_mem_virt2phy((void *)ctx_add= r); - } + dest_addr =3D (phys_addr_t)rte_mem_virt2iova((void *)append_ptr); + ctx_paddr =3D (phys_addr_t)rte_mem_virt2iova((void *)ctx_addr); ctx_addr =3D session->auth.sha3_ctx; @@ -2099,13 +2055,7 @@ ccp_perform_aes_cmac(struct rte_crypto_op *op, ctx_addr =3D session->auth.pre_compute; memset(ctx_addr, 0, AES_BLOCK_SIZE); - if (iommu_mode =3D=3D 2) - pst.src_addr =3D (phys_addr_t)rte_mem_virt2iova( - (void *)ctx_addr); - else - pst.src_addr =3D (phys_addr_t)rte_mem_virt2phy( - (void *)ctx_addr); - + pst.src_addr =3D (phys_addr_t)rte_mem_virt2iova((void=20 + *)ctx_addr); pst.dest_addr =3D (phys_addr_t)(cmd_q->sb_iv * CCP_SB_BYTES= ); pst.len =3D CCP_SB_BYTES; pst.dir =3D 1; @@ -2143,12 +2093,7 @@ ccp_perform_aes_cmac(struct rte_crypto_op *op, } else { ctx_addr =3D session->auth.pre_compute + CCP_SB_BYTES; memset(ctx_addr, 0, AES_BLOCK_SIZE); - if (iommu_mode =3D=3D 2) - pst.src_addr =3D (phys_addr_t)rte_mem_virt2iova( - (void *)ctx_addr); - else - pst.src_addr =3D (phys_addr_t)rte_mem_virt2phy( - (void *)ctx_addr); + pst.src_addr =3D (phys_addr_t)rte_mem_virt2iova((void=20 + *)ctx_addr); pst.dest_addr =3D (phys_addr_t)(cmd_q->sb_iv * CCP_SB_BYTES= ); pst.len =3D CCP_SB_BYTES; pst.dir =3D 1; @@ -2342,12 +2287,7 @@ ccp_perform_3des(struct rte_crypto_op *op, rte_memcpy(lsb_buf + (CCP_SB_BYTES - session->iv.length), iv, session->iv.length); - if (iommu_mode =3D=3D 2) - pst.src_addr =3D (phys_addr_t)rte_mem_virt2iova( - (void *) lsb_buf); - else - pst.src_addr =3D (phys_addr_t)rte_mem_virt2phy( - (void *) lsb_buf); + pst.src_addr =3D (phys_addr_t)rte_mem_virt2iova((void *)=20 + lsb_buf); pst.dest_addr =3D (phys_addr_t)(cmd_q->sb_iv * CCP_SB_BYTES= ); pst.len =3D CCP_SB_BYTES; pst.dir =3D 1; @@ -2370,11 +2310,7 @@ ccp_perform_3des(struct rte_crypto_op *op, else dest_addr =3D src_addr; - if (iommu_mode =3D=3D 2) - key_addr =3D rte_mem_virt2iova(session->cipher.key_ccp); - else - key_addr =3D rte_mem_virt2phy(session->cipher.key_ccp); - + key_addr =3D rte_mem_virt2iova(session->cipher.key_ccp); desc =3D &cmd_q->qbase_desc[cmd_q->qidx]; memset(desc, 0, Q_DESC_SIZE); @@ -2768,12 +2704,7 @@ process_ops_to_enqueue(struct ccp_qp *qp, b_info->lsb_buf_idx =3D 0; b_info->desccnt =3D 0; b_info->cmd_q =3D cmd_q; - if (iommu_mode =3D=3D 2) - b_info->lsb_buf_phys =3D - (phys_addr_t)rte_mem_virt2iova((void *)b_info->lsb_= buf); - else - b_info->lsb_buf_phys =3D - (phys_addr_t)rte_mem_virt2phy((void *)b_info->lsb_b= uf); + b_info->lsb_buf_phys =3D (phys_addr_t)rte_mem_virt2iova((void=20 + *)b_info->lsb_buf); rte_atomic64_sub(&b_info->cmd_q->free_slots, slots_req); diff --git a/drivers/crypto/ccp/ccp_dev.c b/drivers/crypto/ccp/ccp_dev.c in= dex 410e62121e..14c54929c4 100644 --- a/drivers/crypto/ccp/ccp_dev.c +++ b/drivers/crypto/ccp/ccp_dev.c @@ -23,7 +23,6 @@ #include "ccp_pci.h" #include "ccp_pmd_private.h" -int iommu_mode; struct ccp_list ccp_list =3D TAILQ_HEAD_INITIALIZER(ccp_list); static int= ccp_dev_id; @@ -652,7 +651,7 @@ is_ccp_device(const char *dirname, static int ccp_pro= be_device(int ccp_type, struct rte_pci_device *pci_dev) { - struct ccp_device *ccp_dev =3D NULL; + struct ccp_device *ccp_dev; ccp_dev =3D rte_zmalloc("ccp_device", sizeof(*ccp_dev), RTE_CACHE_LINE_SIZE); @@ -683,16 +682,10 @@ c= cp_probe_devices(struct rte_pci_device *pci_dev, struct dirent *d; DIR *dir; int ret =3D 0; - int module_idx =3D 0; uint16_t domain; uint8_t bus, devid, function; char dirname[PATH_MAX]; - module_idx =3D ccp_check_pci_uio_module(); - if (module_idx < 0) - return -1; - - iommu_mode =3D module_idx; TAILQ_INIT(&ccp_list); dir =3D opendir(SYSFS_PCI_DEVICES); if (dir =3D=3D NULL) diff --git a/drivers/crypto/ccp/ccp_pci.c b/drivers/crypto/ccp/ccp_pci.c in= dex c941e222c7..bd1a037f76 100644 --- a/drivers/crypto/ccp/ccp_pci.c +++ b/drivers/crypto/ccp/ccp_pci.c @@ -11,40 +11,6 @@ #include #include "ccp_pci.h" -#include "ccp_pmd_private.h" - -static const char * const uio_module_names[] =3D { - "igb_uio", - "uio_pci_generic", - "vfio_pci" -}; - -int -ccp_check_pci_uio_module(void) -{ - FILE *fp; - int i; - char buf[BUFSIZ]; - - fp =3D fopen(PROC_MODULES, "r"); - if (fp =3D=3D NULL) - return -1; - i =3D 0; - while (uio_module_names[i] !=3D NULL) { - while (fgets(buf, sizeof(buf), fp) !=3D NULL) { - if (!strncmp(buf, uio_module_names[i], - strlen(uio_module_names[i]))) { - fclose(fp); - return i; - } - } - i++; - rewind(fp); - } - fclose(fp); - CCP_LOG_DBG("Insert igb_uio or uio_pci_generic kernel module(s)"); - return -1;/* uio not inserted */ -} /* * split up a pci address into its constituent parts. diff --git a/drivers/crypto/ccp/ccp_pci.h b/drivers/crypto/ccp/ccp_pci.h in= dex 6736bf8ad3..d9a8b9dcc6 100644 --- a/drivers/crypto/ccp/ccp_pci.h +++ b/drivers/crypto/ccp/ccp_pci.h @@ -10,9 +10,6 @@ #include #define SYSFS_PCI_DEVICES "/sys/bus/pci/devices" -#define PROC_MODULES "/proc/modules" - -int ccp_check_pci_uio_module(void); int ccp_parse_pci_addr_format(const char *buf, int bufsize, uint16_t *doma= in, uint8_t *bus, uint8_t *devid, uint8_t *functi= on); diff --git a/drivers/crypto/ccp/rte_ccp_pmd.c b/drivers/crypto/ccp/rte= _ccp_pmd.c index 7338ef0ae8..8b3a5a304b 100644 --- a/drivers/crypto/ccp/rte_ccp_pmd.c +++ b/drivers/crypto/ccp/rte_ccp_pmd.c @@ -22,7 +22,6 @@ static unsigned int ccp_pmd_init_done; uint8_t ccp_cryptodev_driver_id; uint8_t cryptodev_cnt; -extern void *sha_ctx; struct ccp_pmd_init_params { struct rte_cryptodev_pmd_init_params def_p; @@ -213,7 +212,6 @@ cry= ptodev_ccp_remove(struct rte_pci_device *pci_dev) return -ENODEV; ccp_pmd_init_done =3D 0; - rte_free(sha_ctx); RTE_LOG(INFO, PMD, "Closing ccp device %s on numa socket %u\n", name, rte_socket_id()); @@ -300,7 +298,6 @@ cryptod= ev_ccp_probe(struct rte_pci_driver *pci_drv __rte_unused, .auth_opt =3D CCP_PMD_AUTH_OPT_CCP, }; - sha_ctx =3D (void *)rte_malloc(NULL, SHA512_DIGEST_SIZE, 64); if (ccp_pmd_init_done) { RTE_LOG(INFO, PMD, "CCP PMD already initialized\n"); return -EFAULT; -- 2.37.3