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 2C497A0C47; Mon, 26 Jul 2021 11:08:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 25B2B40F35; Mon, 26 Jul 2021 11:08:58 +0200 (CEST) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2070.outbound.protection.outlook.com [40.107.212.70]) by mails.dpdk.org (Postfix) with ESMTP id BD80B40DDA for ; Mon, 26 Jul 2021 11:08:56 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NKDkZXfclEGGFNzhrUh0C9P6bAIKMBm68Im24G3G6Mf7iZ3NotMA77mPQFEtkAALBb4YaOITXFLtcmbc2FznGE9g8KtUWqzCAH7EHlwsG8tdnGp1xrl3zrj5t+8RV+6LcH0R9kOOwJWWO8h08TM2/sMGJq2sRTwhTXcQj7V7OGGTUWqJYSD5S7O9jJhRphY8hg2DsyH26gXAqGlzL39Bd7c3P/bWKHcX1+AChvsw//JVmT7Bjcjr/A3Gu5W/2ECBvjgpW3ECni7ApVHx0rqPU4vLKNXC9sYa+IlAqCkCYKahCnRC6yl6oCCEQ/QoTsGJIfxwAfdrGwrarmQ+ArGLKw== 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=bEBO39hp3cuM2Zd5dtAvlB8G0JMw+RXtykmr6SVZqRo=; b=EzjqiG1HNpnj6hrePTRJR2pWk6tDvCZjpCPMOl/5ymcqjPCBRjBfihL8Gy7PxqeNd75bTjXO8MKPbxN1lu20yPd2qtnCoMRV8dJQrh77sz9bG2Dfp1vL+SH6jS7A0B6mRwanVImgk/vp/j5fKfqBkLOY1XAw82MDrDhMNPv89iNu0qXjcpNtDM9VnGn2254FMgphs6g+WroNY5qMEZNHndJAfhhacj91JKIAnbk5l3u8PbsgQX+KecEAI5mHND7yQ0ewvH8/CTWaKf8oZgmWqCGlIZRpjzV/HOYtKR61CYl5kZmPTUPGlmg7z4sCzdpoIb4HoqbfnthaEv6dtOpU8A== 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=bEBO39hp3cuM2Zd5dtAvlB8G0JMw+RXtykmr6SVZqRo=; b=nyGiFrfMbIHWb1URxhR8996f8o14K2V9ond86QWfN/bBtswEn7JfEViu9QgGrZszM01imVrndd5FeJQv74lH2f/s9YwCl2R85BugYJPZ3NWnth+8qUVGP1xI2buhya1aw5cCDS+TsQGp9z0n7ocEo9/9dWCSd2kUh1M3hJ3Xqhw= 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 BYAPR12MB3286.namprd12.prod.outlook.com (2603:10b6:a03:139::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.29; Mon, 26 Jul 2021 09:08:55 +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.4352.031; Mon, 26 Jul 2021 09:08:54 +0000 From: asomalap@amd.com To: dev@dpdk.org Date: Mon, 26 Jul 2021 14:38:21 +0530 Message-Id: <20210726090821.3833862-1-asomalap@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210719044624.3604232-1-asomalap@amd.com> References: <20210719044624.3604232-1-asomalap@amd.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MA1PR0101CA0054.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::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 MA1PR0101CA0054.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:20::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4352.25 via Frontend Transport; Mon, 26 Jul 2021 09:08:53 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6d04d31b-5647-4269-6dad-08d95014fe3c X-MS-TrafficTypeDiagnostic: BYAPR12MB3286: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:499; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pvxyDItQHLY6cKvM3ZU/5KiYxchwsALAOLG3YhYgSKPHhwrSrnmI1XX9rOPFXCshvZh7+u0LF60Nv7XIvTOqqdKVsRgBdYUVktcdmop+DOWN/A2FTEiWhBwXUNan/j/icBjZFA/UobdRSN6gW2f01IhlDzCgyOdIIiO3Azeim+la3WypI/3o+C0c0J2UimkgOQloV+cauW4q37z/fftm8u71DJzFSHAU7U3joD52KrbQdJzBGCGFagJJD+bwqfF12nazVv5dSWiArl7mVE2sYnQvmIXlrfrNdDD4/gheSIs1/NqNCUHZYpGMORjG2LDwNJcgwiOTArdnxfRP+rLttv9IXNDbEw8VRUseRDKDEjl0l5yNitnrpg27XZ9Mdby3U+uDYxmo3Sfta9vT/IK3ETkj6xaheGelsO4XL8dHY73YtjA389Ikzwqfbb05IdvRigEfHZBE4BrfRTyEN6tRG9t4ZIiUsBUUOWrAxcvj0L/NRr5LCks413DNZRTeJ+fzGuOcvfBHL+SuYMHIF6ena2QWHg/i0dVfcAtQ1E9QBVTNS7xQvjA1Kln9Ce0UMP/xdJeqOOXkN2wObHtIOsZGirditFQAdICw7EgdrGkpi+SQJfWT/rIz0iIPv2VFSy5OMNwdgirKup0Hc4b0TMm1NOOW4IFxSyOWHhCj41atchYgtezp+bOooivn8oV/PgaJC/RnZeCNLiiZM1mVrRo4/g== 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)(366004)(39860400002)(396003)(136003)(346002)(376002)(956004)(186003)(38100700002)(2616005)(38350700002)(66476007)(66946007)(316002)(52116002)(2906002)(478600001)(7696005)(6486002)(9686003)(26005)(30864003)(66556008)(6916009)(6666004)(8936002)(8676002)(1076003)(83380400001)(5660300002)(36756003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?lw5Z48ZIhjUDQqd6JIhs0fuEEyqUL13FxQCGIDeaDRZEMWw3RI03Eu2OSPEl?= =?us-ascii?Q?y7ZWT3/Pc+ditKSANCwHyzwlcth6gSE+jTIVGvA0yOCiOUYLGOHDfbZM2t5Y?= =?us-ascii?Q?yyYnY3Fxyfj0lfmprGR0gcx8yzE2wQne9RZZtpROsxSdZXteF/1dekNjkutO?= =?us-ascii?Q?QjuOsoetCrGBmqnonXJTf5HZ9W0KYWrppGj3+aE1xC4at8rM3zSrigM5eT4l?= =?us-ascii?Q?XU7CLZTLgLCXlGiEnQruGI0qfeAbvvqaTZNNXdcN9UJgEFddxBRJVz7Fl5ei?= =?us-ascii?Q?pdfrDjuHwkH0kOMrm/XtTUOkONC0d8ijEvs5lYGgoovkJxoP9e761u8pfwbM?= =?us-ascii?Q?3hMJcQwa+urzoWiGFNfNCDLpW7TaxDXu5PZwOUJdSwfMyIlQSxHc/ZC+xLTF?= =?us-ascii?Q?aGwhaeQtKgA6RsKhZKwc1KW85ERtzfRBpoiAVGhM/tzEYdJhsVCG3VDhV7NX?= =?us-ascii?Q?Xr2XCq+emqCK3h3dEMzOTTwkCkPz6GRt9mjUwunJUa52rJlV+y0SL2FqAKxa?= =?us-ascii?Q?pWE+tw7CiFn8wGv17rjmzhvshPhL+Mv93t0L3NhUjZjS4kyKqNTNYRphJ1xf?= =?us-ascii?Q?j8XkItPMcd1CuCyGLTfRa23lbr6d+x0DdE74DlDAnKVAyTHY3kwgrApEZiuV?= =?us-ascii?Q?czY9cNkZRom3XU3RNpHK8F1tOlqdZyaZBMyk+1Lbu2kQBgclvBwasWj1FLr3?= =?us-ascii?Q?ltMu0DhM67z/N/oXcCjhPeeQTdXxGBPs+JyMbTE+MMQ8f81+Bh60Ak+V9GJr?= =?us-ascii?Q?ogRhtj486OPGhXsUgylnjMnyBzKt1o0BQehdUQdWj9bSt9+a/xa/cmdIKfxD?= =?us-ascii?Q?vjPtEye4jw3dfuQ8yKUYLZfBoHQYG4YnHDx1cl795dPKqw/Wt6LKtDz2hY6I?= =?us-ascii?Q?14QnD9/T1Enn8NlGyGYG37YsQXnkzHpKMs9keyW6mlVtdMxOUztoVkO5AIhY?= =?us-ascii?Q?M2tznc+mQyVKylPkz9H5uKk9wVKTPahr6kxUMP+1/hY4a11yv/vWzsolusVW?= =?us-ascii?Q?7W9t5pdCd0S9axXV9OUX3xYeXvKs/8RWuburQJJhh+lqd6jC2iN5VWG6ktss?= =?us-ascii?Q?lXO64LVwiyO+29yx6YpRpPqaUjBFZRC5fpQOAdo8XRXFGCsqZO7VpOUWQxjC?= =?us-ascii?Q?r7e9h8jsx6pHPi2MP4+EIC2pk7gtYI90GUlOq3dIifEcNPvf+lmGsbvAkLqy?= =?us-ascii?Q?oW83Rle36VtnkmYwRl+0rlqyLVNn0kckuyukDRzeKKAe38S98ZtDX+E/LrQa?= =?us-ascii?Q?93+L+8qN/3IOlchxNMtv9ww0CzPMF1iPmsT1HWjFZqeAnKOdoJ2MNmdmDGhd?= =?us-ascii?Q?Z8mVR/Nh2gcwjPeAqhp2n/19?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d04d31b-5647-4269-6dad-08d95014fe3c X-MS-Exchange-CrossTenant-AuthSource: BYAPR12MB2821.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jul 2021 09:08:54.6945 (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: ifLDQ1z2yMjtX4Po6AQf7bUbsYgv8dvnX0PLchQIlBEbqTy3ZG/saqZbeQEG2Sr3WjNSEw3if1HGqSJ1FZKNSA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3286 Subject: [dpdk-dev] [PATCH v6] crypto/ccp: move device from vdev to PCI 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 developed for enable IOMMU in vdev. Signed-off-by: Amaranath Somalapuram --- V6: - Address the following comments from Akhil and David: - Spellcheck, Title, Changelog V5: - Fix x86_64-native-linuxapp-clang compilation fix in other function V4: - x86_64-native-linuxapp-clang compilation fix created after changing pointer to array V3: - No changes. Ignore this patch V2: - No changes. Ignore this patch --- 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