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 14EA0A0542; Thu, 24 Nov 2022 14:57:14 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A8A1742DC1; Thu, 24 Nov 2022 14:57:13 +0100 (CET) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2077.outbound.protection.outlook.com [40.107.244.77]) by mails.dpdk.org (Postfix) with ESMTP id 2FC4142DBF for ; Thu, 24 Nov 2022 14:57:12 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fAYFicq/Pxqko5/S+P57DX2s72hslat88hReMUra4Wy+2V4TqAUr2zQ5HuryNgKDjw8jNxT8k+tc4q45etU3k0j15RKhgNRqYUXxdjeb/xUGKeCWdPH2t0qu+wrNWTRjLbneWYjFm1B4BPHcQckFTigvBY06Ae/iflI1HG7kWosv8AU0ybJjtxY6xh2zm2NHYfniIkNz6PSBvndMzn6B2GGIElyLXY9ZqsyZyQ9KTeYgfV25fO+zS80q10e474Yz5DHL7mJ8yOck+nHE6y9JXpnpi9mJ/nd935CqA6ljdlFVeOsVVXyw9SIQroBu7bBP5efB1Q4FBmckNjIIBm0PZg== 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=dE1AxrHx+MSz5hXKLKb+wIGauTowR0ah/5eGINIj9ro=; b=Po11/7Z/TMaMLtz3AWThEz7jow6mjFmDmCi3rjlUcLUHs+KB7sxv2vy3T6hQ8Dgns1yGSKGnN87QkM1nykkyR/yFNT1JQxHtw1pq7hubpp2Qp+gR6j4aMo4LavNJOTHba2peGMZu8JjN9iDGvMC0IAez123uSGRwR3uQ3EO48UHX0kxZAGNkZRu3c3sbXiFwzIL4rynNL+uZET1SN+2ZU5OxLSAw80GAsVyFQVRkcxs/94p0ZlL4WZq9mXFhVaM1kYxOlTtGuxfTCqWM892X0SoMcvebFiWWyE2sBHrHz9DtE5Z4FbW7pryztTgPznjrcWTeSdjdInirZq5hHjPCrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=dpdk.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=dE1AxrHx+MSz5hXKLKb+wIGauTowR0ah/5eGINIj9ro=; b=Q6lWUad4zTWyD79FbosPT976z4xnMOfykO/GJlL/xn9/u40jzZPI+7p/TrRCr5cacfgwg4XQk8CyBHR/ajBr4i6xL1aYZJcanfsvNCMTN5gzlEIq1NLBH9Fp7XC9b5G25iJ+udpRiQX/nZnEBE4zixCuRqljef/BI/BOdOH1k9s= Received: from MW4PR02CA0003.namprd02.prod.outlook.com (2603:10b6:303:16d::30) by DS0PR12MB6557.namprd12.prod.outlook.com (2603:10b6:8:d3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5834.11; Thu, 24 Nov 2022 13:57:09 +0000 Received: from CO1NAM11FT040.eop-nam11.prod.protection.outlook.com (2603:10b6:303:16d:cafe::e5) by MW4PR02CA0003.outlook.office365.com (2603:10b6:303:16d::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.19 via Frontend Transport; Thu, 24 Nov 2022 13:57:09 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT040.mail.protection.outlook.com (10.13.174.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5857.17 via Frontend Transport; Thu, 24 Nov 2022 13:57:09 +0000 Received: from cae-Bilby-RV1.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 24 Nov 2022 07:57:07 -0600 From: Sunil Uttarwar To: CC: , Sunil Uttarwar Subject: [PATCH v1] crypto/ccp: bug fixes for ccp device probe flow Date: Thu, 24 Nov 2022 19:26:45 +0530 Message-ID: <20221124135645.5955-1-sunilprakashrao.uttarwar@amd.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT040:EE_|DS0PR12MB6557:EE_ X-MS-Office365-Filtering-Correlation-Id: 7a5c648f-121b-4c75-9c74-08dace23c7ae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JXPUhD1qKV5hRYvlSUL/1z8KFdZvFzoh4gnyJgrsiTqY2mA1FZK1A9v/hb8yEWCkypt9S6b9Zyov0p2/Glkz9fCTZpL3FNCE+RGK3344QnMUo6ZwANAJtuOwvaS+KNnmg5T79EwdwPy2SKWpw0/yaQgP4dDCRX2HgxFTEf5aAXfRHbtQTGM0QpyNLWnHu6ydB3on+19E0264qW3s8mXzqYk4g8x8tu6w4enEj9Odvaapo2hyDXisPpRMUmDHewB9Nkgw8n8K0uI6dzH25yLfiEYCTfZF7g2+FF1DopM3ff33v3V1QHsY1RTgn/y+xNcKhyWoLtwa2feiYwttjtawgiZBrCJVrzi6B0+PzivaCPwV2JtpEWXHHrDfkVEyUGYvjciqiwwmdsBoABrVYalDjgaeoGhWvOkdqT5Z0YNhEFogR7NtHE6RYZQlAcO2InbuqABCq/v2Lbq6hZjh764DOf9UUcr2ZomZVBD0vNZK5PpbnMD58/Sa1GL+MyoKB762Z6Osg4Sq6kOGjjY67NQwpaV65S9Fj8eqjiAmSmgPlzh693R5U0ZjkQ6rBgpHhTAgJGim54reBj4mUJwI/gvX5EiThgKLLAsHc0cKgTv4JXB2VGukGWOh2m8diqqCCHaxQZGUKYOjbON6DQEBpe2Jeg8pZojaiQ7FcLHYMrcM9lqZpYFDTs5+ikI2fZ5Zz+4FgX6fDejRj8YFojsMY5bMVDxnvEv6h3MfE0NP7vD3zrM= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB04.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230022)(4636009)(376002)(396003)(136003)(39860400002)(346002)(451199015)(40470700004)(46966006)(36840700001)(86362001)(40480700001)(83380400001)(6666004)(2906002)(5660300002)(70206006)(336012)(316002)(2616005)(6916009)(7696005)(70586007)(54906003)(40460700003)(4326008)(426003)(478600001)(26005)(356005)(36756003)(8936002)(82740400003)(81166007)(36860700001)(8676002)(47076005)(41300700001)(186003)(82310400005)(16526019)(1076003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Nov 2022 13:57:09.4226 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7a5c648f-121b-4c75-9c74-08dace23c7ae X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d; Ip=[165.204.84.17]; Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT040.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR12MB6557 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 - Fixed flow for probe and initialization of requested ccp devices - Removed unnecessary code enumerating for all the PCI devices available in the system. - Removed ccp_pmd_init_done flag controlling probe and initialization of only one CCP device even if other CCP devices available Signed-off-by: Sunil Uttarwar --- drivers/crypto/ccp/ccp_dev.c | 28 ++++++++++------------------ drivers/crypto/ccp/rte_ccp_pmd.c | 7 ------- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/drivers/crypto/ccp/ccp_dev.c b/drivers/crypto/ccp/ccp_dev.c index 424ead82c3..9e3c2d6a63 100644 --- a/drivers/crypto/ccp/ccp_dev.c +++ b/drivers/crypto/ccp/ccp_dev.c @@ -683,13 +683,11 @@ ccp_probe_devices(struct rte_pci_device *pci_dev, { int dev_cnt = 0; int ccp_type = 0; - struct dirent *d; DIR *dir; int ret = 0; int module_idx = 0; - uint16_t domain; - uint8_t bus, devid, function; char dirname[PATH_MAX]; + char name[RTE_CRYPTODEV_NAME_MAX_LEN]; module_idx = ccp_check_pci_uio_module(); if (module_idx < 0) @@ -700,21 +698,15 @@ ccp_probe_devices(struct rte_pci_device *pci_dev, dir = opendir(SYSFS_PCI_DEVICES); if (dir == NULL) return -1; - while ((d = readdir(dir)) != NULL) { - if (d->d_name[0] == '.') - continue; - if (ccp_parse_pci_addr_format(d->d_name, sizeof(d->d_name), - &domain, &bus, &devid, &function) != 0) - continue; - snprintf(dirname, sizeof(dirname), "%s/%s", - SYSFS_PCI_DEVICES, d->d_name); - if (is_ccp_device(dirname, ccp_id, &ccp_type)) { - printf("CCP : Detected CCP device with ID = 0x%x\n", - ccp_id[ccp_type].device_id); - ret = ccp_probe_device(ccp_type, pci_dev); - if (ret == 0) - dev_cnt++; - } + rte_pci_device_name(&pci_dev->addr, name, sizeof(name)); + snprintf(dirname, sizeof(dirname), "%s/%s", + SYSFS_PCI_DEVICES, name); + if (is_ccp_device(dirname, ccp_id, &ccp_type)) { + printf("CCP : Detected CCP device with ID = 0x%x\n", + ccp_id[ccp_type].device_id); + ret = ccp_probe_device(ccp_type, pci_dev); + if (ret == 0) + dev_cnt++; } closedir(dir); return dev_cnt; diff --git a/drivers/crypto/ccp/rte_ccp_pmd.c b/drivers/crypto/ccp/rte_ccp_pmd.c index 221a0a5235..ea77d79efc 100644 --- a/drivers/crypto/ccp/rte_ccp_pmd.c +++ b/drivers/crypto/ccp/rte_ccp_pmd.c @@ -19,7 +19,6 @@ /** * Global static parameter used to find if CCP device is already initialized. */ -static unsigned int ccp_pmd_init_done; uint8_t ccp_cryptodev_driver_id; uint8_t cryptodev_cnt; extern void *sha_ctx; @@ -199,7 +198,6 @@ cryptodev_ccp_remove(struct rte_pci_device *pci_dev) if (dev == NULL) return -ENODEV; - ccp_pmd_init_done = 0; rte_free(sha_ctx); RTE_LOG(INFO, PMD, "Closing ccp device %s on numa socket %u\n", @@ -288,10 +286,6 @@ cryptodev_ccp_probe(struct rte_pci_driver *pci_drv __rte_unused, }; sha_ctx = (void *)rte_malloc(NULL, SHA512_DIGEST_SIZE, 64); - if (ccp_pmd_init_done) { - RTE_LOG(INFO, PMD, "CCP PMD already initialized\n"); - return -EFAULT; - } rte_pci_device_name(&pci_dev->addr, name, sizeof(name)); if (name[0] == '\0') return -EINVAL; @@ -310,7 +304,6 @@ cryptodev_ccp_probe(struct rte_pci_driver *pci_drv __rte_unused, rc = cryptodev_ccp_create(name, pci_dev, &init_params, pci_drv); if (rc) return rc; - ccp_pmd_init_done = 1; return 0; } -- 2.25.1