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 EE7D6A0C51; Fri, 16 Jul 2021 14:03:21 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9D19A4067B; Fri, 16 Jul 2021 14:03:21 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2052.outbound.protection.outlook.com [40.107.237.52]) by mails.dpdk.org (Postfix) with ESMTP id 90FA340151 for ; Fri, 16 Jul 2021 14:03:19 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ijTJMhPz1ukONBwhIqtL/PQsITYgjZk6sqSsd1rColKfXzwVmS64Gn1ypyk98ukmh1E8XNGQ/JoNF+SwgT7JBJJoDQBwwPl0qFo7BHRpjitTla+PTV5G86lOfz3/wNjTyNr1VfBtCdWJN72SFDnUBItU2vAxsi+qlKXLQ8u+3hzfJfDeFnUo1nwLebscDaQhKHdz7M+0Oz07sxzeekCwkXaOZ4TgMHTxLpzSoQ7OTKOaZeSsrxIsaIun+xhFIOe2StNoLSVf1esXCzJ7JuIevRm7u64BUm5Jg6PvwMWXGr/Uquk+MSaQnvOk5ybicW21+3use5aFGC0EQM0ahTZ4wA== 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=vUbRfvlQm1PpZo0/HdHNA0+kENpff/4ZNPvGoNb9x70=; b=h8oEVNhIvWbXyaKbzDk4ok7F/LvHP9sCmqPG36OgtS5KyZLdXboK/QDd4seVhtt9N6h3QawHUutoePeSeHfNqRY/bL6CaUPdKxU5oF0abgSnNxRZOqklpBB9Gea+6KFZZQ6ZSpND3lKrHDnm3JSMi74pCNqmc5+B9jfomRBtRwt7MiXvqMwhw83I0O84jyfQ/EoJTFecfrHsUs2FjIo7nCj/Vy0j7p7m5ZjiVwjHUHQ2tJn2vVd4aED6Zif5sjIZ45ieEcjaSZSOu9xFLIzq0Nm7YP+CCeK/enwyZvrNGBzN2AErU9XB9NmubjIzMMu7Q31hNQ0BSE1unHdhjwaRMA== 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=vUbRfvlQm1PpZo0/HdHNA0+kENpff/4ZNPvGoNb9x70=; b=2AbGFCRZwBvuLp1Fi+kUQYqZgj/yYGAZCC+t1ArWf4hlyLq0z1mq3LMdy3t8aI3rLSNGQ54Wnusc/jXYbfHioWbVoUC1sin+I0vQ0vCsQxFCQrnw8d/nwvbKZ0EgvyOwG1hK/4coAqaWuL7KFidH5KJGLmkl9MA7ILgCIZCDpL4= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=amd.com; Received: from BYAPR12MB2821.namprd12.prod.outlook.com (2603:10b6:a03:9b::30) by BY5PR12MB4035.namprd12.prod.outlook.com (2603:10b6:a03:206::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21; Fri, 16 Jul 2021 12:03:16 +0000 Received: from BYAPR12MB2821.namprd12.prod.outlook.com ([fe80::7d70:4f93:e25e:ebf4]) by BYAPR12MB2821.namprd12.prod.outlook.com ([fe80::7d70:4f93:e25e:ebf4%5]) with mapi id 15.20.4308.027; Fri, 16 Jul 2021 12:03:16 +0000 From: asomalap@amd.com To: dev@dpdk.org Date: Fri, 16 Jul 2021 17:32:55 +0530 Message-Id: <20210716120255.3475871-1-asomalap@amd.com> X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MA1PR01CA0127.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:35::21) To BYAPR12MB2821.namprd12.prod.outlook.com (2603:10b6:a03:9b::30) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from cae-Wallaby.amd.com (165.204.157.251) by MA1PR01CA0127.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:35::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Fri, 16 Jul 2021 12:03:15 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8a48c287-6d6e-481a-caf6-08d94851b19d X-MS-TrafficTypeDiagnostic: BY5PR12MB4035: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:446; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E1N5NOOqJXoSb/f71ezbFuCjljrZx2w3MWYCyRPncDJUD3i3dHDquaAcNGD1ywhdDxmMCKww2iLYt6YJhJlP0K6LRHbJSuDhUwDuqr8RDx3H8N2vzs7Wrs4tyfOpvl/xThqgCd0xLS4BleLKWIfaD3TwSbtz6kKkXNYFrrmSAmq88sEbUP05oRxS+9ADWqMtIhJn7tmJwO+2YtfXbw2FMWxbvLu8AvaoUpPqVXvoqV2Zpn4WvFSOT9M7HB5ZonEcTOYjaCDNcFd8mQCMw7tsPZb96AmitN3ScjvHjVullpch61TERmQcKDd+aF1ec0ugvRRd2DpoWDzi0pScSd4Cyc4VihabocSi5jnSCqgfSN3EytPkR8jxy9CD3dcoQIH2Iimdpaw2HJwZ0ILIfJaifgh/HIQcA5PZ1UKnNLfwAQeuL5fvlczgA/5MjJk7cOG/Ze2nbaTXRimu1DNgZpBPBcBBJ3Hp7x/wDOnqr3BIh5QVmIujn6dFOPrcGUH7IM/UYdJZWul2V7Gf3D5lAOvnnWSvKO2Q73uCdLJysluaRIahH/XhArNQhydp4evr/lvGZE9DQ1ZMq/2rMDjoSOFx/6ADm/KWFDXZvfTkysm3FKPL71+/CdCPwpfsUHkSnxh0POq2tyF33dH6Xk3jCSr6FtLMST5JMNfSNmatjk8IW3/HEIrfvy9IqYFuxLSijorQx79p1Ipdi0v86HCTuRY8jQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BYAPR12MB2821.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(396003)(346002)(366004)(136003)(39860400002)(6666004)(38350700002)(30864003)(5660300002)(2616005)(956004)(26005)(38100700002)(1076003)(66946007)(186003)(66556008)(66476007)(6486002)(316002)(478600001)(83380400001)(2906002)(52116002)(7696005)(6916009)(8676002)(8936002)(9686003)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?rw31B/CXRE0ilEiGqGw0she010Wmb/OjR496e8p2ct5V1Wo2gWoTbvTu4BzJ?= =?us-ascii?Q?I0mv+UGhNaGFJb9EQqUO8yoC2tz+MuCXnWf2C5g7C3kAPfPfuSZm06xOJMhM?= =?us-ascii?Q?GZfn69/dHb+EX3qvxE/JIY8qHzjIWZT6p2S5C3Ufj0rYAY0EcqbVS0zdBnYp?= =?us-ascii?Q?+eM0YpCliM5hTzoUltiVbnHpb02j95U1yU1U04RRrTNg1Z4kX6MJ9i1LjNNK?= =?us-ascii?Q?89UgcBHFJbp52gDfV59mpxZGAZv7Aikyx+2AOAwoaXc/eDG7amafML5/JeXF?= =?us-ascii?Q?TDZs+vpiEUY91p4+ftNXb4bIEoJCJ3fLVUhXk9N2ylDAcmtGCftpZJM0O29p?= =?us-ascii?Q?eg62+lVhtgvD0dSObASxy1MmDQ4QcoQvWAPjWLGgsBouisYfSJFTUWfJ25e7?= =?us-ascii?Q?MLnYvksfFi2vqU5UOTaTsucmfTfLNpUsTg6ZIDrusvRktYATw720+OUcNI9+?= =?us-ascii?Q?a6L5CSvSEUoiVezqDK/FlDdLc6bCLgdR+OLKSy6xzC5uwJRRK5C4FU2D2yOx?= =?us-ascii?Q?6GnbYwFuyn6g8DfpBwX+DRRx3pggKKPYGtlB5JF1CyYmIAwv92uGyd+m2zra?= =?us-ascii?Q?VZuE/uQSNk/DufbWk53zKUEZh9RNOJNlrlwjhZ5/TuUhryBjv8MbSd/OEkIL?= =?us-ascii?Q?mz1evMUuHwb3v3t4RTmtN2c9sVT83zI5HY88QdCrQhUOYNgL94v5ajdv+lkS?= =?us-ascii?Q?og91XsOyqp4SNDCTaL/j9kR5wrviPJtsxdIsVZGNzij/NXqKyjHMvskuAmZV?= =?us-ascii?Q?SIPu+he/Lt1YTCBRj/PPU6S79ephb6ub9lgueX60wQP0KFqxS4NDn8SNA9UV?= =?us-ascii?Q?GgVKoqr2/W9ButrNGjqFp6zRjru2YgfDiuMzO3EjlP1UtJoKWWSUhrOj0Okc?= =?us-ascii?Q?jQm95HRnUBKDL4loapUcMt16YawUMD+TmZyNrP31VZJCl3I72W6wYypHWzXz?= =?us-ascii?Q?gBAAZig09gZTw0SgtXDWnPjyyR1a9EG+GAJIkTYX7wPzc9vhGDa7DRn0b3JB?= =?us-ascii?Q?fruiYIUXphoeamM6854Uab/Mly6stnDM1yIHX+izazH+xtaWGigyiOy8jS/V?= =?us-ascii?Q?VjSdzxP0DGFL9OGSX5ugMs5ybE2O8of1MCoXC2ucO+Jointc2SUtXgOxIXOK?= =?us-ascii?Q?puvizNMD+J03jeRiN484cGrUSvlgKuSEySaqWtI+Os9bsyNYdvyH3PCVy2vq?= =?us-ascii?Q?Xi2d7Q5dJ+wvuGgIKuZk1cK+vM5gZqVzw2lB/XDiT6yWUlyCSnJgrBXzOrFn?= =?us-ascii?Q?lvXaxKgRg1EE/7R1bRs2NvLG6JTZcCtZJ1uMzYQxVOet8XezxJ8PcU4UofTk?= =?us-ascii?Q?S/kVRgpP2JciyMggfgQ61s90?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8a48c287-6d6e-481a-caf6-08d94851b19d X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB2821.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jul 2021 12:03:16.0814 (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: H7GhsIGxZPUFP2aL041QKfsA3ReHdsUHA4PCcAUHni3MG3C28GDUIokY8CJYNN//SYNupGFb3UtM0g+IhQibnA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4035 Subject: [dpdk-dev] [PATCH v4] crypto/ccp: moving vdev to PCI driver 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 Sender: "dev" From: Amaranath Somalapuram drop all the code duplicating the PCI bus driver develped for Enable IOMMU in vdev. Signed-off-by: Amaranath Somalapuram --- drivers/crypto/ccp/ccp_dev.c | 66 +------------ drivers/crypto/ccp/ccp_dev.h | 3 +- drivers/crypto/ccp/rte_ccp_pmd.c | 158 +++++++------------------------ 3 files changed, 41 insertions(+), 186 deletions(-) diff --git a/drivers/crypto/ccp/ccp_dev.c b/drivers/crypto/ccp/ccp_dev.c index ee6882b8a4..0eb1b0328e 100644 --- a/drivers/crypto/ccp/ccp_dev.c +++ b/drivers/crypto/ccp/ccp_dev.c @@ -650,73 +650,17 @@ is_ccp_device(const char *dirname, } static int -ccp_probe_device(const char *dirname, uint16_t domain, - uint8_t bus, uint8_t devid, - uint8_t function, int ccp_type) +ccp_probe_device(int ccp_type, struct rte_pci_device *pci_dev) { struct ccp_device *ccp_dev = NULL; - struct rte_pci_device *pci; - char filename[PATH_MAX]; - unsigned long tmp; int uio_fd = -1; ccp_dev = rte_zmalloc("ccp_device", sizeof(*ccp_dev), RTE_CACHE_LINE_SIZE); if (ccp_dev == NULL) goto fail; - pci = &(ccp_dev->pci); - - pci->addr.domain = domain; - pci->addr.bus = bus; - pci->addr.devid = devid; - pci->addr.function = function; - - /* get vendor id */ - snprintf(filename, sizeof(filename), "%s/vendor", dirname); - if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0) - goto fail; - pci->id.vendor_id = (uint16_t)tmp; - - /* get device id */ - snprintf(filename, sizeof(filename), "%s/device", dirname); - if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0) - goto fail; - pci->id.device_id = (uint16_t)tmp; - - /* get subsystem_vendor id */ - snprintf(filename, sizeof(filename), "%s/subsystem_vendor", - dirname); - if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0) - goto fail; - pci->id.subsystem_vendor_id = (uint16_t)tmp; - - /* get subsystem_device id */ - snprintf(filename, sizeof(filename), "%s/subsystem_device", - dirname); - if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0) - goto fail; - pci->id.subsystem_device_id = (uint16_t)tmp; - - /* get class_id */ - snprintf(filename, sizeof(filename), "%s/class", - dirname); - if (ccp_pci_parse_sysfs_value(filename, &tmp) < 0) - goto fail; - /* the least 24 bits are valid: class, subclass, program interface */ - pci->id.class_id = (uint32_t)tmp & RTE_CLASS_ANY_ID; - - /* parse resources */ - snprintf(filename, sizeof(filename), "%s/resource", dirname); - if (ccp_pci_parse_sysfs_resource(filename, pci) < 0) - goto fail; - if (iommu_mode == 2) - pci->kdrv = RTE_PCI_KDRV_VFIO; - else if (iommu_mode == 0) - pci->kdrv = RTE_PCI_KDRV_IGB_UIO; - else if (iommu_mode == 1) - pci->kdrv = RTE_PCI_KDRV_UIO_GENERIC; - rte_pci_map_device(pci); + ccp_dev->pci = *pci_dev; /* device is valid, add in list */ if (ccp_add_device(ccp_dev, ccp_type)) { @@ -735,7 +679,8 @@ ccp_probe_device(const char *dirname, uint16_t domain, } int -ccp_probe_devices(const struct rte_pci_id *ccp_id) +ccp_probe_devices(struct rte_pci_device *pci_dev, + const struct rte_pci_id *ccp_id) { int dev_cnt = 0; int ccp_type = 0; @@ -767,8 +712,7 @@ ccp_probe_devices(const struct rte_pci_id *ccp_id) 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(dirname, domain, bus, devid, - function, ccp_type); + ret = ccp_probe_device(ccp_type, pci_dev); if (ret == 0) dev_cnt++; } diff --git a/drivers/crypto/ccp/ccp_dev.h b/drivers/crypto/ccp/ccp_dev.h index 37e04218ce..ca5145c278 100644 --- a/drivers/crypto/ccp/ccp_dev.h +++ b/drivers/crypto/ccp/ccp_dev.h @@ -473,7 +473,8 @@ int ccp_dev_start(struct rte_cryptodev *dev); * @param ccp_id rte_pci_id list for supported CCP devices * @return no. of successfully initialized CCP devices */ -int ccp_probe_devices(const struct rte_pci_id *ccp_id); +int ccp_probe_devices(struct rte_pci_device *pci_dev, + const struct rte_pci_id *ccp_id); /** * allocate a ccp command queue diff --git a/drivers/crypto/ccp/rte_ccp_pmd.c b/drivers/crypto/ccp/rte_ccp_pmd.c index ba379a19f3..84a650d9f5 100644 --- a/drivers/crypto/ccp/rte_ccp_pmd.c +++ b/drivers/crypto/ccp/rte_ccp_pmd.c @@ -47,111 +47,6 @@ enum ccp_pmd_auth_opt { CCP_PMD_AUTH_OPT_CPU, }; -/** parse integer from integer argument */ -static int -parse_integer_arg(const char *key __rte_unused, - const char *value, void *extra_args) -{ - int *i = (int *) extra_args; - - *i = atoi(value); - if (*i < 0) { - CCP_LOG_ERR("Argument has to be positive.\n"); - return -EINVAL; - } - - return 0; -} - -/** parse name argument */ -static int -parse_name_arg(const char *key __rte_unused, - const char *value, void *extra_args) -{ - struct rte_cryptodev_pmd_init_params *params = extra_args; - - if (strlen(value) >= RTE_CRYPTODEV_NAME_MAX_LEN - 1) { - CCP_LOG_ERR("Invalid name %s, should be less than " - "%u bytes.\n", value, - RTE_CRYPTODEV_NAME_MAX_LEN - 1); - return -EINVAL; - } - - strncpy(params->name, value, RTE_CRYPTODEV_NAME_MAX_LEN); - - return 0; -} - -/** parse authentication operation option */ -static int -parse_auth_opt_arg(const char *key __rte_unused, - const char *value, void *extra_args) -{ - struct ccp_pmd_init_params *params = extra_args; - int i; - - i = atoi(value); - if (i < CCP_PMD_AUTH_OPT_CCP || i > CCP_PMD_AUTH_OPT_CPU) { - CCP_LOG_ERR("Invalid ccp pmd auth option. " - "0->auth on CCP(default), " - "1->auth on CPU\n"); - return -EINVAL; - } - params->auth_opt = i; - return 0; -} - -static int -ccp_pmd_parse_input_args(struct ccp_pmd_init_params *params, - const char *input_args) -{ - struct rte_kvargs *kvlist = NULL; - int ret = 0; - - if (params == NULL) - return -EINVAL; - - if (input_args) { - kvlist = rte_kvargs_parse(input_args, - ccp_pmd_valid_params); - if (kvlist == NULL) - return -1; - - ret = rte_kvargs_process(kvlist, - CCP_CRYPTODEV_PARAM_MAX_NB_QP, - &parse_integer_arg, - ¶ms->def_p.max_nb_queue_pairs); - if (ret < 0) - goto free_kvlist; - - ret = rte_kvargs_process(kvlist, - CCP_CRYPTODEV_PARAM_SOCKET_ID, - &parse_integer_arg, - ¶ms->def_p.socket_id); - if (ret < 0) - goto free_kvlist; - - ret = rte_kvargs_process(kvlist, - CCP_CRYPTODEV_PARAM_NAME, - &parse_name_arg, - ¶ms->def_p); - if (ret < 0) - goto free_kvlist; - - ret = rte_kvargs_process(kvlist, - CCP_CRYPTODEV_PARAM_AUTH_OPT, - &parse_auth_opt_arg, - params); - if (ret < 0) - goto free_kvlist; - - } - -free_kvlist: - rte_kvargs_free(kvlist); - return ret; -} - static struct ccp_session * get_ccp_session(struct ccp_qp *qp, struct rte_crypto_op *op) { @@ -300,12 +195,21 @@ static struct rte_pci_id ccp_pci_id[] = { /** Remove ccp pmd */ static int -cryptodev_ccp_remove(struct rte_vdev_device *dev) +cryptodev_ccp_remove(struct rte_pci_device *pci_dev) { - const char *name; + char name[RTE_CRYPTODEV_NAME_MAX_LEN]; + struct rte_cryptodev *dev; + + if (pci_dev == NULL) + return -EINVAL; + + rte_pci_device_name(&pci_dev->addr, name, sizeof(name)); + + dev = rte_cryptodev_pmd_get_named_dev(name); + if (dev == NULL) + return -ENODEV; ccp_pmd_init_done = 0; - name = rte_vdev_device_name(dev); rte_free(sha_ctx); if (name == NULL) return -EINVAL; @@ -313,14 +217,15 @@ cryptodev_ccp_remove(struct rte_vdev_device *dev) RTE_LOG(INFO, PMD, "Closing ccp device %s on numa socket %u\n", name, rte_socket_id()); - return 0; + return rte_cryptodev_pmd_destroy(dev); } /** Create crypto device */ static int cryptodev_ccp_create(const char *name, - struct rte_vdev_device *vdev, - struct ccp_pmd_init_params *init_params) + struct rte_pci_device *pci_dev, + struct ccp_pmd_init_params *init_params, + struct rte_pci_driver *pci_drv) { struct rte_cryptodev *dev; struct ccp_private *internals; @@ -330,14 +235,14 @@ cryptodev_ccp_create(const char *name, sizeof(init_params->def_p.name)); dev = rte_cryptodev_pmd_create(init_params->def_p.name, - &vdev->device, + &pci_dev->device, &init_params->def_p); if (dev == NULL) { CCP_LOG_ERR("failed to create cryptodev vdev"); goto init_error; } - cryptodev_cnt = ccp_probe_devices(ccp_pci_id); + cryptodev_cnt = ccp_probe_devices(pci_dev, ccp_pci_id); if (cryptodev_cnt == 0) { CCP_LOG_ERR("failed to detect CCP crypto device"); @@ -345,6 +250,8 @@ cryptodev_ccp_create(const char *name, } printf("CCP : Crypto device count = %d\n", cryptodev_cnt); + dev->device = &pci_dev->device; + dev->device->driver = &pci_drv->driver; dev->driver_id = ccp_cryptodev_driver_id; /* register rx/tx burst functions for data path */ @@ -368,17 +275,18 @@ cryptodev_ccp_create(const char *name, init_error: CCP_LOG_ERR("driver %s: %s() failed", init_params->def_p.name, __func__); - cryptodev_ccp_remove(vdev); + cryptodev_ccp_remove(pci_dev); return -EFAULT; } /** Probe ccp pmd */ static int -cryptodev_ccp_probe(struct rte_vdev_device *vdev) +cryptodev_ccp_probe(struct rte_pci_driver *pci_drv __rte_unused, + struct rte_pci_device *pci_dev) { int rc = 0; - const char *name; + char name[RTE_CRYPTODEV_NAME_MAX_LEN]; struct ccp_pmd_init_params init_params = { .def_p = { "", @@ -388,19 +296,16 @@ cryptodev_ccp_probe(struct rte_vdev_device *vdev) }, .auth_opt = CCP_PMD_AUTH_OPT_CCP, }; - const char *input_args; 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; } - name = rte_vdev_device_name(vdev); - if (name == NULL) + rte_pci_device_name(&pci_dev->addr, name, sizeof(name)); + if (name[0] == '\0') return -EINVAL; - input_args = rte_vdev_device_args(vdev); - ccp_pmd_parse_input_args(&init_params, input_args); init_params.def_p.max_nb_queue_pairs = CCP_PMD_MAX_QUEUE_PAIRS; RTE_LOG(INFO, PMD, "Initialising %s on NUMA node %d\n", name, @@ -410,21 +315,26 @@ cryptodev_ccp_probe(struct rte_vdev_device *vdev) RTE_LOG(INFO, PMD, "Authentication offload to %s\n", ((init_params.auth_opt == 0) ? "CCP" : "CPU")); - rc = cryptodev_ccp_create(name, vdev, &init_params); + rte_pci_device_name(&pci_dev->addr, name, sizeof(name)); + + rc = cryptodev_ccp_create(name, pci_dev, &init_params, pci_drv); if (rc) return rc; ccp_pmd_init_done = 1; return 0; } -static struct rte_vdev_driver cryptodev_ccp_pmd_drv = { +static struct rte_pci_driver cryptodev_ccp_pmd_drv = { + .id_table = ccp_pci_id, + .drv_flags = RTE_PCI_DRV_NEED_MAPPING, .probe = cryptodev_ccp_probe, .remove = cryptodev_ccp_remove }; static struct cryptodev_driver ccp_crypto_drv; -RTE_PMD_REGISTER_VDEV(CRYPTODEV_NAME_CCP_PMD, cryptodev_ccp_pmd_drv); +RTE_PMD_REGISTER_PCI(CRYPTODEV_NAME_CCP_PMD, cryptodev_ccp_pmd_drv); +RTE_PMD_REGISTER_KMOD_DEP(CRYPTODEV_NAME_CCP_PMD, "* igb_uio | uio_pci_generic | vfio-pci"); RTE_PMD_REGISTER_PARAM_STRING(CRYPTODEV_NAME_CCP_PMD, "max_nb_queue_pairs= " "socket_id= " -- 2.25.1