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 BA7E8A0C45; Mon, 19 Jul 2021 06:46:55 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 36A234068B; Mon, 19 Jul 2021 06:46:55 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2071.outbound.protection.outlook.com [40.107.94.71]) by mails.dpdk.org (Postfix) with ESMTP id 56EEF4067A for ; Mon, 19 Jul 2021 06:46:53 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RE2XBGcOxo4HXE0JQ4vB9ScI45BroVAiJ98Z3TUIIoM+xjUva8VDaeueUUaEjwZnaLSVyUzHGSQ8aS4Fic1CgJCdWdVdmgrB/qogNF8kqZTO3EzDhcSY6sQ4Ln2EZWk/H+9JKAhU83Nm43goX9Aae6BTZCupwp69He5NCzwRKwaDkZtMacwFwxsAPPLdGz7OhA7KTD2+sf155nDPvpj4zHzgF6TtsyKY5pPeVOtu54GGajFodkiVHQDIeLM8RwsTsnM75OBwXjXA5UbNLqexk5xUCaoisPwq24T0Lgd0BEL1BkqEavcqy5SxZvnnFI6/n9btYdxZDXCSE76Ka1Xjcw== 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=CAHcfgzaf4XD5cC1tE5NTfLYXYX85+64VAIklY8poMU=; b=XkfRVEeIIXNP2XoL/l6SCxaLQxcT19Lkg0AVnopGxzFXlPfQFQ/c3HpPe4rC1nR/02Bomn5uinJe6V9Ng0wAzE2KaLucpXEac3BYWVd3ZA2yNAZMz/acl3PuFy5YlHBfHO1DOjxVS/smjzpmgCDDPIOgGZInBqUbbXRXazhjn7Dq+M4TzdQA2l4sXHayX8s4/S+5dQ4ujtLpxwUTC85NA40QntQPVueg8OcpmGKcbdp3NhUk8gKsUrbw8Ni/3ppPoMJZrPTuEuB0xUSen2KJIrY+JLOHNia60pIUD2IsHypz7Pj7th5fr9B4cV5dNwVdGO914Fg2HpO7VrkJe5mHSA== 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=CAHcfgzaf4XD5cC1tE5NTfLYXYX85+64VAIklY8poMU=; b=dzvVvm7HYLi8VvxcGDPgZCO0AABrAfZ3ZDj6JMz0PH96cnDaPDJA/ioR5NDrCGzE0eSltMDka4ApHKwDygJ6Ux31FNIVaMLyfvm2sumMn4Z9eXAOl5SWHSspMctv3Tz/P9Jje9/7rH51nED29RvdcYUKkB9mTkUNHcmXWAMGTTE= 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 BYAPR12MB2791.namprd12.prod.outlook.com (2603:10b6:a03:61::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21; Mon, 19 Jul 2021 04:46:50 +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.4331.032; Mon, 19 Jul 2021 04:46:50 +0000 From: asomalap@amd.com To: dev@dpdk.org Date: Mon, 19 Jul 2021 10:16:24 +0530 Message-Id: <20210719044624.3604232-1-asomalap@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210716120255.3475871-1-asomalap@amd.com> References: <20210716120255.3475871-1-asomalap@amd.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MAXPR0101CA0030.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:d::16) 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 MAXPR0101CA0030.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4331.21 via Frontend Transport; Mon, 19 Jul 2021 04:46:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5b7f99bd-a013-470c-96e0-08d94a7038ac X-MS-TrafficTypeDiagnostic: BYAPR12MB2791: 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: 62gtejUGEngkfjG1gC5BxyVWw0XLjf7uLmvTSUa8sSqiaJ1uysZky4+Jc5xVzACTaiYrU+RjmEeya5WZRrY7YSHHA9NlpZmavv2d6atiC61wr7+mLEoYAuXXfxyn6RukN15UZG6DrWiRUC80Pps0cnj6uy+SHNX7knkrlR++qiU0Xy92yuXahIYB4F81f6hiLiLXGg3jbeB22nSDAvhzchGdEjxu9jbCrw66OHOmm8TJiAwKfr9wVJNAJRuigfPBknfNPpGBbSYtBQc40NR8ULTXJpMU1UJurlKfF6hiitMWDsX0fsgTs94reb4+avo1DS177pavYuveMqsJCMfA8dvdKtKDOsI57VnOn01Y8ZtnZSS3m+0+PixkFmHtrXju3LOLFZ2PWA2aMz5oe8U/AFxX2d716iVLz4W+VUlXF04JMJL8UiU74e800gAgcEv4cD8w6kJ1/REaNqCWokNp6xr43rJ3bO02c3oUKDuu3IlQEERImJ4t8wvaYhW9lGVMek3wKIBbQvuKkVF7exG4GKXlcb77swmHSmYwgzsoPHtI/XJ2YtpySJQtUZZV42aHWpVZTovpPBwcwdcJhVLO+EUdzm3ew7Qs8KUkMQL8fiXgzYkU0Dq+zCcVPBkZ9oU9T95mbY2Z8BmpOcPsINSnVGava1CDGade6oNUTpPxbEN3Gpi3xjrgBIAsFKxjvwGSez4dQdw07Qb3TH2o7y7AzA== 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)(396003)(136003)(346002)(376002)(366004)(39860400002)(36756003)(52116002)(7696005)(5660300002)(6666004)(30864003)(8676002)(8936002)(316002)(66476007)(83380400001)(9686003)(66946007)(66556008)(6916009)(38350700002)(956004)(1076003)(38100700002)(6486002)(478600001)(186003)(2906002)(2616005)(26005); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?Kyhm626gNbs+n0xOu/NPviqjGu7WKoGSUaE2b09fOL3OLCiimk6Caf5A2uB7?= =?us-ascii?Q?VOWMDSSXsA3ABB1w1sv6cwskEwvnOQltXA6aIE7o2Ci2kjMDpesRv8CMe2t1?= =?us-ascii?Q?Ry/p6YW7r6NZgRcnH8Gf4fYOYoD1ElomJtwsOXrKQedOwJ6Jugfeq7vnEmZZ?= =?us-ascii?Q?dGJxxR5QMa8F3IhtKbtm1Z9Pz6jxBRvS+aXn8S5EJRABc4yxNsbTufs9dmlb?= =?us-ascii?Q?b/wTJes4m02ZOzNtJIWc90lMCc3jQPKOedkkDI/2HrWav9bjhiLH4fK/6UrG?= =?us-ascii?Q?XosN+0q+ygPlhcWFmNWQIOivnVNXvdATwN17Yw9qG3Wul81f65rgaV9H143H?= =?us-ascii?Q?5WZ5gIo+FMT+e/DdbT3HlX1VQgvezhtjM1eSIr1SIciyX/vrdbX7xj4hsy++?= =?us-ascii?Q?/FNcb0GS7rBI33pYs1qbeloC00kYWtsHc1FjdKOg1rEoRdM4x3qWGI4mBaBC?= =?us-ascii?Q?jRT3Z6pLogcVQW4Op3Tfdj6BHGZ4eKiGCCIEqEVqNXWeGRTuEy+ioe/jeJ54?= =?us-ascii?Q?JOmIT6Zks8uJMfgt84nEmNecMHLajK5mrlP41a5FwPrGZkatN4A5M3uBy34S?= =?us-ascii?Q?HNGS/f5wYE9zNToPIfyJsBADtTJ6Xpirq/0t4kaA7QY7upHiBsbYPeePfmgU?= =?us-ascii?Q?Z24E61bROpbH//vHGVjdemCrmvu+mBWh0RVqFejJ/w2Kl4cq7SW3bv4aet/p?= =?us-ascii?Q?lmwfHJl0dI5VGFfD5WScKOOeUz58ED4sTbL1liyP8NfkEC4ihinS7YOvUEAW?= =?us-ascii?Q?3lxsipOML8E/GcGUD9N6TSrC7nQ7Iwtjq5MDkOUgd0Em8u7020+GjBTWW5lR?= =?us-ascii?Q?Hom8/J8eNSrwfkoYgccqqs1hn93SxSNffgYMNg1JcPRjBfE/cUGnALlOEh60?= =?us-ascii?Q?+mqJ60QlPwxLPEEmOe3zXz7fudC/3G+wG+sl/UtuKYiz2OI0sp4Ae/q0vHU8?= =?us-ascii?Q?Xv7pOmpC6KCsHINE3juq58jyUbrir3LSb39sCrj+k2rprJGUhVLeORR/soSU?= =?us-ascii?Q?XdvHy8fYyceEr4VwaMzo+OdvkCLVIkUt1OWAqWSONvk/dJkQsZ2pPwyTmX+Z?= =?us-ascii?Q?I3mAYz+/C+4eAtoOgbmSerDfxfmqX9mTUmm3Zi/oMbNiGPEeUnLxxoRXnp47?= =?us-ascii?Q?hlsTMak4+TPoJwcvAGvIQR/PAbNxANj6NPmPZ8ihURBNlYQ+fwgXkujHYNJ1?= =?us-ascii?Q?2bQuJlo3I0nbX8x9t5h2BWFzSKttulKqjAvK2Ricm5dVw7kXvkROeKUb4XVd?= =?us-ascii?Q?XiYENbsixMvyyA4mByiS68PhrNR3DrJl0892W0vUnEc9m5TNEe9bXvlcuW1C?= =?us-ascii?Q?fa3ea4G376e6g+YqIWVV5eFC?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5b7f99bd-a013-470c-96e0-08d94a7038ac X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB2821.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jul 2021 04:46:50.0051 (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: UQzzdxULwS9Ebp4IBccar+VTsMMwGrv1IuUyNrFvjBq1OC2nDPK8WqPqO5a0eYWg/tb/tyGnf91jHIcW9vg1HA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2791 Subject: [dpdk-dev] [PATCH v5] 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 | 163 +++++++------------------------ 3 files changed, 44 insertions(+), 188 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..ab9416942e 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,27 +195,38 @@ 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)); + + if (name[0] == '\0') + return -EINVAL; + + 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; 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 +236,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 +251,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 +276,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 +297,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 +316,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